October\Rain\Assetic\Factory\AssetFactory

The asset factory creates asset objects.

Public methods

public void __construct(string $root, Boolean $debug=false)

Constructor.

Parameters
  • string $root - The default root directory
  • Boolean $debug - Filters prefixed with a "?" will be omitted in debug mode

public void addWorker(WorkerInterface $worker)

Adds a factory worker.

Parameters
  • WorkerInterface $worker - A worker

public AssetCollection createAsset(array|string $inputs=array(), array|string $filters=array(), array $options=array())

Creates a new asset.

Prefixing a filter name with a question mark will cause it to be omitted when the factory is in debug mode.

Available options:

  • output: An output string
  • name: An asset name for interpolation in output patterns
  • debug: Forces debug mode on or off for this asset
  • root: An array or string of more root directories
Parameters
  • array|string $inputs - An array of input strings
  • array|string $filters - An array of filter names
  • array $options - An array of options

public void generateAssetName($inputs, $filters, $options=array())
Parameters
  • $inputs
  • $filters
  • $options

public AssetManager|null getAssetManager()

Returns the current asset manager.

public FilterManager|null getFilterManager()

Returns the current filter manager.

public void getLastModified($asset)
Parameters
  • $asset

public Boolean isDebug()

Checks if the factory is in debug mode.

public void setAssetManager(AssetManager $am)

Sets the asset manager to use when creating asset references.

Parameters
  • AssetManager $am - The asset manager

public void setDebug(Boolean $debug)

Sets debug mode for the current factory.

Parameters
  • Boolean $debug - Debug mode

public void setDefaultOutput(string $output)

Sets the default output string.

Parameters
  • string $output - The default output string

public void setFilterManager(FilterManager $fm)

Sets the filter manager to use when adding filters.

Parameters
  • FilterManager $fm - The filter manager

Protected methods

protected void createAssetCollection($assets=array(), $options=array())
Parameters
  • $assets
  • $options

protected void createAssetReference($name)
Parameters
  • $name

protected void createFileAsset($source, $root=NULL, $path=NULL, $vars=array())
Parameters
  • $source
  • $root
  • $path
  • $vars

protected void createGlobAsset($glob, $root=NULL, $vars=array())
Parameters
  • $glob
  • $root
  • $vars

protected void createHttpAsset($sourceUrl, $vars)
Parameters
  • $sourceUrl
  • $vars

protected void getFilter($name)
Parameters
  • $name

protected AssetInterface parseInput(string $input, array $options=array())

Parses an input string string into an asset.

The input string can be one of the following:

  • A reference: If the string starts with an "at" sign it will be interpreted as a reference to an asset in the asset manager
  • An absolute URL: If the string contains "://" or starts with "//" it will be interpreted as an HTTP asset
  • A glob: If the string contains a "*" it will be interpreted as a glob
  • A path: Otherwise the string is interpreted as a filesystem path

Both globs and paths will be absolutized using the current root directory.

Parameters
  • string $input - An input string
  • array $options - An array of options