AssetFactory creates asset objects.

Protected Properties

protected mixed $root

protected mixed $debug

protected mixed $output

protected mixed $am

protected mixed $fm

Public Methods

public __construct()

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

public createAsset()

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

createAsset 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

public generateAssetName()

public generateAssetName($inputs, $filters, $options = []): void

public getAssetManager()

public getAssetManager(): AssetManager|null 

Returns the current asset manager.

public getFilterManager()

public getFilterManager(): FilterManager|null 

Returns the current filter manager.

public getLastModified()

public getLastModified($asset): void

public isDebug()

public isDebug(): Boolean 

Checks if the factory is in debug mode.

public setAssetManager()

public setAssetManager(AssetManager $am): void

Sets the asset manager to use when creating asset references.

public setDebug()

public setDebug(Boolean $debug): void

Sets debug mode for the current factory.

public setDefaultOutput()

public setDefaultOutput(string $output): void

Sets the default output string.

public setFilterManager()

public setFilterManager(FilterManager $fm): void

Sets the filter manager to use when adding filters.

Protected Methods

protected createAssetCollection()

protected createAssetCollection($assets = [], $options = []): void

protected createFileAsset()

protected createFileAsset($source, $root = null, $path = null, $vars = []): void

protected createGlobAsset()

protected createGlobAsset($glob, $root = null, $vars = []): void

protected createHttpAsset()

protected createHttpAsset($sourceUrl, $vars): void

protected getFilter()

protected getFilter($name): void

protected parseInput()

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

Parses an input string string into an asset.

The input string can be one of the following:

  • 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.