CoreFiles by mySites.guru
CoreAssetItem.php54 lines, 1,388 bytes, from Joomla_4.2.2-Stable-Full_Package.zip
Raw History Compare with 4.2.1
md5
903e08bf806c3bcb4d8f0d637047d37c
sha1
a83ca0696f49b50c6ff3635f1d6a2eb75e6c7b17
sha256
b67beb727a30325fc103fea75467e860696b2c232471bfa4776436387b8281f2
<?php

/**
 * Joomla! Content Management System
 *
 * @copyright  (C) 2019 Open Source Matters, Inc. <https://www.joomla.org>
 * @license    GNU General Public License version 2 or later; see LICENSE.txt
 */

namespace Joomla\CMS\WebAsset\AssetItem;

use Joomla\CMS\Document\Document;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Uri\Uri;
use Joomla\CMS\WebAsset\WebAssetAttachBehaviorInterface;
use Joomla\CMS\WebAsset\WebAssetItem;

// phpcs:disable PSR1.Files.SideEffects
\defined('JPATH_PLATFORM') or die;
// phpcs:enable PSR1.Files.SideEffects

/**
 * Web Asset Item class for Core asset
 *
 * @since  4.0.0
 */
class CoreAssetItem extends WebAssetItem implements WebAssetAttachBehaviorInterface
{
    /**
     * Method called when asset attached to the Document.
     * Useful for Asset to add a Script options.
     *
     * @param   Document  $doc  Active document
     *
     * @return void
     *
     * @since   4.0.0
     */
    public function onAttachCallback(Document $doc)
    {
        // Add core and base uri paths so javascript scripts can use them.
        $doc->addScriptOptions(
            'system.paths',
            [
                'root' => Uri::root(true),
                'rootFull' => Uri::root(),
                'base' => Uri::base(true),
                'baseFull' => Uri::base(),
            ]
        );

        HTMLHelper::_('form.csrf');
    }
}

The same content is in 17 releases, Joomla 4.2.1 to 4.3.0-alpha3. See them all, or every version of this file.