CoreFiles by mySites.guru
LangActiveAssetItem.php58 lines, 1,699 bytes, from Joomla_5.0.2-Stable-Full_Package.zip
Raw History Compare with 5.0.1
md5
7d8ef58bd8c17e4079dac523f9c8295c
sha1
2faf11f742d0231f74a0bef3ae83424c11446f22
sha256
1a0b0391d3dc7f4cc0e29e247ef8ab32c0cd51f59a472d971485fafc5e9722b7
<?php

/**
 * Joomla! Content Management System
 *
 * @copyright  (C) 2020 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\Factory;
use Joomla\CMS\WebAsset\WebAssetItem;

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

/**
 * Web Asset Item class for load asset file for active language.
 * Used in core templates.
 *
 * @since  4.0.0
 */
class LangActiveAssetItem extends WebAssetItem
{
    /**
     * Class constructor
     *
     * @param   string  $name          The asset name
     * @param   string  $uri           The URI for the asset
     * @param   array   $options       Additional options for the asset
     * @param   array   $attributes    Attributes for the asset
     * @param   array   $dependencies  Asset dependencies
     *
     * @since   4.0.0
     */
    public function __construct(
        string $name,
        string $uri = null,
        array $options = [],
        array $attributes = [],
        array $dependencies = []
    ) {
        parent::__construct($name, $uri, $options, $attributes, $dependencies);

        // Prepare Uri depend from the active language
        $langTag = Factory::getApplication()->getLanguage()->getTag();
        $client  = $this->getOption('client');

        // Create Uri <client>/language/<langTag>/<langTag>.css
        if ($client) {
            $this->uri = $client . '/language/' . $langTag . '/' . $langTag . '.css';
        } else {
            $this->uri = 'language/' . $langTag . '/' . $langTag . '.css';
        }
    }
}

The same content is in 41 releases, Joomla 5.0.0-alpha1 to 5.2.0-alpha3. See them all, or every version of this file.