[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/src/WebAsset/AssetItem/ -> CoreAssetItem.php (source)

   1  <?php
   2  
   3  /**
   4   * Joomla! Content Management System
   5   *
   6   * @copyright  (C) 2019 Open Source Matters, Inc. <https://www.joomla.org>
   7   * @license    GNU General Public License version 2 or later; see LICENSE.txt
   8   */
   9  
  10  namespace Joomla\CMS\WebAsset\AssetItem;
  11  
  12  use Joomla\CMS\Document\Document;
  13  use Joomla\CMS\HTML\HTMLHelper;
  14  use Joomla\CMS\Uri\Uri;
  15  use Joomla\CMS\WebAsset\WebAssetAttachBehaviorInterface;
  16  use Joomla\CMS\WebAsset\WebAssetItem;
  17  
  18  // phpcs:disable PSR1.Files.SideEffects
  19  \defined('JPATH_PLATFORM') or die;
  20  // phpcs:enable PSR1.Files.SideEffects
  21  
  22  /**
  23   * Web Asset Item class for Core asset
  24   *
  25   * @since  4.0.0
  26   */
  27  class CoreAssetItem extends WebAssetItem implements WebAssetAttachBehaviorInterface
  28  {
  29      /**
  30       * Method called when asset attached to the Document.
  31       * Useful for Asset to add a Script options.
  32       *
  33       * @param   Document  $doc  Active document
  34       *
  35       * @return void
  36       *
  37       * @since   4.0.0
  38       */
  39      public function onAttachCallback(Document $doc)
  40      {
  41          // Add core and base uri paths so javascript scripts can use them.
  42          $doc->addScriptOptions(
  43              'system.paths',
  44              [
  45                  'root' => Uri::root(true),
  46                  'rootFull' => Uri::root(),
  47                  'base' => Uri::base(true),
  48                  'baseFull' => Uri::base(),
  49              ]
  50          );
  51  
  52          HTMLHelper::_('form.csrf');
  53      }
  54  }


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer