[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

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

   1  <?php
   2  
   3  /**
   4   * Joomla! Content Management System
   5   *
   6   * @copyright  (C) 2020 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\Factory;
  13  use Joomla\CMS\WebAsset\WebAssetItem;
  14  
  15  // phpcs:disable PSR1.Files.SideEffects
  16  \defined('JPATH_PLATFORM') or die;
  17  // phpcs:enable PSR1.Files.SideEffects
  18  
  19  /**
  20   * Web Asset Item class for load asset file for active language.
  21   * Used in core templates.
  22   *
  23   * @since  4.0.0
  24   */
  25  class LangActiveAssetItem extends WebAssetItem
  26  {
  27      /**
  28       * Class constructor
  29       *
  30       * @param   string  $name          The asset name
  31       * @param   string  $uri           The URI for the asset
  32       * @param   array   $options       Additional options for the asset
  33       * @param   array   $attributes    Attributes for the asset
  34       * @param   array   $dependencies  Asset dependencies
  35       *
  36       * @since   4.0.0
  37       */
  38      public function __construct(
  39          string $name,
  40          string $uri = null,
  41          array $options = [],
  42          array $attributes = [],
  43          array $dependencies = []
  44      ) {
  45          parent::__construct($name, $uri, $options, $attributes, $dependencies);
  46  
  47          // Prepare Uri depend from the active language
  48          $langTag = Factory::getApplication()->getLanguage()->getTag();
  49          $client  = $this->getOption('client');
  50  
  51          // Create Uri <client>/language/<langTag>/<langTag>.css
  52          if ($client) {
  53              $this->uri = $client . '/language/' . $langTag . '/' . $langTag . '.css';
  54          } else {
  55              $this->uri = 'language/' . $langTag . '/' . $langTag . '.css';
  56          }
  57      }
  58  }


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