- md5
- d4b83c6574c34f59bced0e6ad7e83121
- sha1
- 55dd5a8a0e646c76163e6cee89bddd5944f84ffb
- sha256
- 55da2828ba8d82e16f47bf4de5f50774ce8a0839cbcd4d59bf7120df5963e293
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
<?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');
if (!$langTag) {
return;
}
// 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 60 releases, Joomla 5.4.1-rc1 to 6.2.1-rc1. See them all, or every version of this file.