PHP Class Sprockets\Pipeline

Show file Open project: nami-doc/sprockets-php

Public Methods

Method Description
__construct ( $paths, $prefix = '' )
__invoke ( $t, $m = null, $v = [], $f = false ) Alias for {@link process()}
addDependency ( string $type, string $path ) adds the $path to dependency list of $type using type-based dependencies to, for example, allow a css file to rely on a .png file
applyFilter ( string $content, string $filter, string $file, $dir, array $vars ) : string apply a filter used for singletonization of filters
getCacheDirectory ( ) : string
getCurrentInstance ( ) : Pipeline singleton
getDependencies ( string $type ) : array returns dependency list for the given $type
getDependenciesFileContent ( string $type ) : string returns dependency list formatted for storing
getFilter ( string $name ) : string fitler singleton
getLocator ( )
getMainFile ( string $type ) returns the main file for a certain type proxies to the Locator
getManifestName ( )
getOption ( $name ) fetches an option
getPrefix ( )
getRegisteredFiles ( string $type = null ) auto-vivificates $this->registered_files (shouldn't be needed)
process ( string $type, string $manifest = null, array $vars = [], boolean $full = false ) : string | array Runs the pipeline
registerFile ( $type, $from, $to ) if we have multiple filters, the mapping will be overrided so that we know last file's name :).
registerFilter ( string $ext, string $class ) registers a special extension the class must be an instance of \Sprockets\Filter\Base
setOptions ( array $options ) set options (destructively) or defaults

Private Methods

Method Description
getFilterClass ( $name ) finds filter class

Method Details

__construct() public method

public __construct ( $paths, $prefix = '' )

__invoke() public method

Alias for {@link process()}
public __invoke ( $t, $m = null, $v = [], $f = false )

addDependency() public method

adds the $path to dependency list of $type using type-based dependencies to, for example, allow a css file to rely on a .png file
public addDependency ( string $type, string $path )
$type string dependency type (application.$type)
$path string file path (x.png, for example)

applyFilter() public method

apply a filter used for singletonization of filters
public applyFilter ( string $content, string $filter, string $file, $dir, array $vars ) : string
$content string content to apply filter on
$filter string filter name
$file string file name (for errors / cache naming)
$vars array context
return string $content with $filter processed on

getCacheDirectory() public method

public getCacheDirectory ( ) : string
return string the cache directory used by Sprockets

getCurrentInstance() public static method

singleton
public static getCurrentInstance ( ) : Pipeline
return Pipeline current pipeline instance

getDependencies() public method

returns dependency list for the given $type
public getDependencies ( string $type ) : array
$type string dependency type (application.$type)
return array files dependent for the type

getDependenciesFileContent() public method

returns dependency list formatted for storing
public getDependenciesFileContent ( string $type ) : string
$type string dependency type (application.$type)
return string file formatted "path:mtime\npath:..."

getFilter() public method

fitler singleton
public getFilter ( string $name ) : string
$name string filter name
return string Filter\iFilter

getLocator() public method

public getLocator ( )

getMainFile() public method

returns the main file for a certain type proxies to the Locator
public getMainFile ( string $type )
$type string asset type

getManifestName() public method

public getManifestName ( )

getOption() public method

fetches an option
public getOption ( $name )

getPrefix() public method

public getPrefix ( )

getRegisteredFiles() public method

auto-vivificates $this->registered_files (shouldn't be needed)
public getRegisteredFiles ( string $type = null )
$type string file type or null for the whole array

process() public method

Runs the pipeline
public process ( string $type, string $manifest = null, array $vars = [], boolean $full = false ) : string | array
$type string asset type
$manifest string main file, "application.$type" by default
$vars array context for the pipeline (vars you pass to templates)
$full boolean True if you want an array containing file list and content
return string | array string unless $full

registerFile() public method

could use an array tho, to keep track of every "step" (but not if no caching is used)
public registerFile ( $type, $from, $to )

registerFilter() public method

registers a special extension the class must be an instance of \Sprockets\Filter\Base
public registerFilter ( string $ext, string $class )
$ext string Extension
$class string Filter class

setOptions() public method

set options (destructively) or defaults
public setOptions ( array $options )
$options array