Spork Code Libraries

AbstractCompiler

Base class for CSS Preprocessor. Provides basic configuration, Service Manager Factory Interface and compile method.

Child classes must implement getCommandArguments method and should override compiler, extensions and configurationKey methods.

abstract
Implements

Properties

$arguments

$arguments : array

Option arguments to be passed to compiler

Type

array

$cache

$cache : \Zend\Cache\Storage\Adapter\AbstractAdapter

Type

\Zend\Cache\Storage\Adapter\AbstractAdapter

$compiler

$compiler : string

Full path to compiler executable

Type

string

$compress

$compress : boolean

Type

boolean

$configurationKey

$configurationKey : string

Key name for options in configuration file.

Add definition in child class to enable service configuration

Type

string

$extensions

$extensions : array

List of file extension of source files

Type

array

$includes

$includes : array

List of inlude paths for compiler to use

Type

array

Methods

compile()

compile(string  $source, string|null  $destination = null, array|string|null  $include = null) : string

Compile to file. If destination is not specified return CSS.

Parameters

string $source
string|null $destination
array|string|null $include

Include path(s) to use

Throws

\Exception

on compilation error

Returns

string —

Compiled CSS

getArguments()

getArguments() : array

Get compiler arguments

Returns

array

setArguments()

setArguments(array  $arguments) 

Set compiler arguments

Parameters

array $arguments

getCache()

getCache() : \Zend\Cache\Storage\Adapter\AbstractAdapter

Get cache

Returns

\Zend\Cache\Storage\Adapter\AbstractAdapter

setCache()

setCache(string|array|\Zend\Cache\Storage\Adapter\AbstractAdapter  $cache) 

Set cache for CSS Preprocessor

Cache parameter can be an instance of \Zend\Cache\Storage\Adapter\AbstractAdapter, the name of a cache adapter class or an array of options to be passed to AbstractAdapter::factory()

Parameters

string|array|\Zend\Cache\Storage\Adapter\AbstractAdapter $cache

Throws

\Exception

on invalid cache

getCompiler()

getCompiler() : string

Get compiler path

Returns

string

setCompiler()

setCompiler(string  $compiler) 

Set compiler path

Parameters

string $compiler

Compiler Path

getCompress()

getCompress() : boolean

Get compress flag

Returns

boolean

setCompress()

setCompress(boolean  $flag) 

Set compress flag

Parameters

boolean $flag

getExtensions()

getExtensions() : string

Get source file extension

Returns

string

setExtensions()

setExtensions(array  $extensions) 

Set source file extensions

Parameters

array $extensions

addInclude()

addInclude(  $include) 

Parameters

$include

getIncludes()

getIncludes() : string|boolean|NULL

Get compiler include path

Returns

string|boolean|NULL

setIncludes()

setIncludes(array  $includes) 

Set compiler include path

If set to true the source path is used.

Parameters

array $includes

createService()

createService(\Zend\ServiceManager\ServiceLocatorInterface  $services) : \Spork\Style\AbstractStyle

Create Service

Parameters

\Zend\ServiceManager\ServiceLocatorInterface $services

Returns

\Spork\Style\AbstractStyle
See also

getCommandArguments()

getCommandArguments(string  $source, string  $destination, array  $includes) : string

Return command line arguments to compile source file or path. If destination is not specified command should print code to standard out.

Parameters

string $source

Source file or path

string $destination

Destination file or path

array $includes

List of include paths

Returns

string
abstract

configure()

configure(array  $options) 

configure

Parameters

array $options

getOptions()

getOptions(\Zend\ServiceManager\ServiceLocatorInterface  $services, string  $key) : array

Get options from application configuration

Parameters

\Zend\ServiceManager\ServiceLocatorInterface $services
string $key

Returns

array