CoreFiles by mySites.guru
LangActiveAssetItem.php58 lines, 1,705 bytes, from Joomla_5.3.3-Stable-Full_Package.zip
Raw History Compare with 5.3.2
md5
628ba55dd2b45fae00be2e5aa67e6b7e
sha1
98c5ce3b1879d76a7a92a9c08e0bf027c5577429
sha256
edb4463ad35d7384ccd411a36f245c461571d126243f5409d3dc5ae2b1dc4de3
<?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 54 releases, Joomla 5.2.0-beta1 to 6.0.0. See them all, or every version of this file.