PHP Class yii\web\AssetConverter

It is used by AssetManager to convert files after they have been published.
Since: 2.0
Author: Qiang Xue ([email protected])
Inheritance: extends yii\base\Component, implements yii\web\AssetConverterInterface
Afficher le fichier Open project: yiisoft/yii2 Class Usage Examples

Méthodes publiques

Свойство Type Description
$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.

Méthodes publiques

Méthode Description
convert ( string $asset, string $basePath ) : string Converts a given asset file into a CSS or JS file.

Méthodes protégées

Méthode Description
runCommand ( string $command, string $basePath, string $asset, string $result ) : boolean Runs a command to convert asset files.

Method Details

convert() public méthode

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.
Résultat string the converted asset file path, relative to $basePath.

runCommand() protected méthode

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
Résultat boolean true on success, false on failure. Failures will be logged.

Property Details

$commands public_oe property

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 public_oe property

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