Back to LangActiveAssetItem class

Method __construct

public
__construct
(string $name, string $uri = null, array $options = [], array $attributes = [], array $dependencies = [])
Class constructor
Parameters
  • string $name The asset name
  • string $uri The URI for the asset
  • array $options Additional options for the asset
  • array $attributes Attributes for the asset
  • array $dependencies Asset dependencies
Since
  • 4.0.0

Method __construct - Source code

/**
 * 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';
    }
}