PHP Класс yii\web\AssetConverter

It is used by AssetManager to convert files after they have been published.
С версии: 2.0
Автор: Qiang Xue ([email protected])
Наследование: extends yii\base\Component, implements yii\web\AssetConverterInterface
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$commands the commands that are used to perform the asset conversion. The keys are the asset file extension names, and the values are the corresponding target script types (either "css" or "js") and the commands used for the conversion. You may also use a path alias to specify the location of the command: php [ 'styl' => ['css', '@app/node_modules/bin/stylus < {from} > {to}'], ]
$forceConvert whether the source asset file should be converted even if its result already exists. You may want to set this to be true during the development stage to make sure the converted assets are always up-to-date. Do not set this to true on production servers as it will significantly degrade the performance.

Открытые методы

Метод Описание
convert ( string $asset, string $basePath ) : string Converts a given asset file into a CSS or JS file.

Защищенные методы

Метод Описание
runCommand ( string $command, string $basePath, string $asset, string $result ) : boolean Runs a command to convert asset files.

Описание методов

convert() публичный Метод

Converts a given asset file into a CSS or JS file.
public convert ( string $asset, string $basePath ) : string
$asset string the asset file path, relative to $basePath
$basePath string the directory the $asset is relative to.
Результат string the converted asset file path, relative to $basePath.

runCommand() защищенный Метод

Runs a command to convert asset files.
protected runCommand ( string $command, string $basePath, string $asset, string $result ) : boolean
$command string the command to run. If prefixed with an `@` it will be treated as a path alias.
$basePath string asset base path and command working directory
$asset string the name of the asset file
$result string the name of the file to be generated by the converter command
Результат boolean true on success, false on failure. Failures will be logged.

Описание свойств

$commands публичное свойство

the commands that are used to perform the asset conversion. The keys are the asset file extension names, and the values are the corresponding target script types (either "css" or "js") and the commands used for the conversion. You may also use a path alias to specify the location of the command: php [ 'styl' => ['css', '@app/node_modules/bin/stylus < {from} > {to}'], ]
public $commands

$forceConvert публичное свойство

whether the source asset file should be converted even if its result already exists. You may want to set this to be true during the development stage to make sure the converted assets are always up-to-date. Do not set this to true on production servers as it will significantly degrade the performance.
public $forceConvert