ILIAS  release_5-2 Revision v5.2.25-18-g3f80b82851
Assetic\Filter\ScssphpFilter Class Reference

Loads SCSS files using the PHP implementation of scss, scssphp. More...

+ Inheritance diagram for Assetic\Filter\ScssphpFilter:
+ Collaboration diagram for Assetic\Filter\ScssphpFilter:

Public Member Functions

 enableCompass ($enable=true)
 
 isCompassEnabled ()
 
 setFormatter ($formatter)
 
 setVariables (array $variables)
 
 addVariable ($variable)
 
 setImportPaths (array $paths)
 
 addImportPath ($path)
 
 registerFunction ($name, $callable)
 
 filterLoad (AssetInterface $asset)
 Filters an asset after it has been loaded. More...
 
 filterDump (AssetInterface $asset)
 Filters an asset just before it's dumped. More...
 
 getChildren (AssetFactory $factory, $content, $loadPath=null)
 Returns child assets. More...
 

Private Attributes

 $compass = false
 
 $importPaths = array()
 
 $customFunctions = array()
 
 $formatter
 
 $variables = array()
 

Detailed Description

Loads SCSS files using the PHP implementation of scss, scssphp.

Scss files are mostly compatible, but there are slight differences.

Bart van den Burg bart@.nosp@m.sams.nosp@m.on-it.nosp@m..nl

Definition at line 28 of file ScssphpFilter.php.

Member Function Documentation

◆ addImportPath()

Assetic\Filter\ScssphpFilter::addImportPath (   $path)

Definition at line 79 of file ScssphpFilter.php.

References $path.

80  {
81  $this->importPaths[] = $path;
82  }
$path
Definition: aliased.php:25

◆ addVariable()

Assetic\Filter\ScssphpFilter::addVariable (   $variable)

Definition at line 69 of file ScssphpFilter.php.

70  {
71  $this->variables[] = $variable;
72  }

◆ enableCompass()

Assetic\Filter\ScssphpFilter::enableCompass (   $enable = true)

Definition at line 36 of file ScssphpFilter.php.

37  {
38  $this->compass = (Boolean) $enable;
39  }

◆ filterDump()

Assetic\Filter\ScssphpFilter::filterDump ( AssetInterface  $asset)

Filters an asset just before it's dumped.

Parameters
AssetInterface$assetAn asset

Implements Assetic\Filter\FilterInterface.

Definition at line 120 of file ScssphpFilter.php.

121  {
122  }

◆ filterLoad()

Assetic\Filter\ScssphpFilter::filterLoad ( AssetInterface  $asset)

Filters an asset after it has been loaded.

Parameters
AssetInterface$assetAn asset

Implements Assetic\Filter\FilterInterface.

Definition at line 89 of file ScssphpFilter.php.

References $path, Assetic\Asset\AssetInterface\getContent(), Assetic\Asset\AssetInterface\getSourceDirectory(), and Assetic\Asset\AssetInterface\setContent().

90  {
91  $sc = new Compiler();
92 
93  if ($this->compass) {
94  new \scss_compass($sc);
95  }
96 
97  if ($dir = $asset->getSourceDirectory()) {
98  $sc->addImportPath($dir);
99  }
100 
101  foreach ($this->importPaths as $path) {
102  $sc->addImportPath($path);
103  }
104 
105  foreach ($this->customFunctions as $name => $callable) {
106  $sc->registerFunction($name, $callable);
107  }
108 
109  if ($this->formatter) {
110  $sc->setFormatter($this->formatter);
111  }
112 
113  if (!empty($this->variables)) {
114  $sc->setVariables($this->variables);
115  }
116 
117  $asset->setContent($sc->compile($asset->getContent()));
118  }
$path
Definition: aliased.php:25
+ Here is the call graph for this function:

◆ getChildren()

Assetic\Filter\ScssphpFilter::getChildren ( AssetFactory  $factory,
  $content,
  $loadPath = null 
)

Returns child assets.

Parameters
AssetFactory$factoryThe asset factory
string$contentThe asset content
string$loadPathAn optional load path
Returns
AssetInterface[] Child assets

Implements Assetic\Filter\DependencyExtractorInterface.

Definition at line 124 of file ScssphpFilter.php.

References $file, $path, array, Assetic\Factory\AssetFactory\createAsset(), and Assetic\Util\CssUtils\extractImports().

125  {
126  $sc = new Compiler();
127  if ($loadPath !== null) {
128  $sc->addImportPath($loadPath);
129  }
130 
131  foreach ($this->importPaths as $path) {
132  $sc->addImportPath($path);
133  }
134 
135  $children = array();
136  foreach (CssUtils::extractImports($content) as $match) {
137  $file = $sc->findImport($match);
138  if ($file) {
139  $children[] = $child = $factory->createAsset($file, array(), array('root' => $loadPath));
140  $child->load();
141  $children = array_merge($children, $this->getChildren($factory, $child->getContent(), $loadPath));
142  }
143  }
144 
145  return $children;
146  }
$path
Definition: aliased.php:25
static extractImports($content)
Extracts all references from the supplied CSS content.
Definition: CssUtils.php:125
Create styles array
The data for the language used.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
getChildren(AssetFactory $factory, $content, $loadPath=null)
Returns child assets.
+ Here is the call graph for this function:

◆ isCompassEnabled()

Assetic\Filter\ScssphpFilter::isCompassEnabled ( )

Definition at line 41 of file ScssphpFilter.php.

References Assetic\Filter\ScssphpFilter\$compass.

42  {
43  return $this->compass;
44  }

◆ registerFunction()

Assetic\Filter\ScssphpFilter::registerFunction (   $name,
  $callable 
)

Definition at line 84 of file ScssphpFilter.php.

85  {
86  $this->customFunctions[$name] = $callable;
87  }

◆ setFormatter()

Assetic\Filter\ScssphpFilter::setFormatter (   $formatter)

Definition at line 46 of file ScssphpFilter.php.

References Assetic\Filter\ScssphpFilter\$formatter, and array.

47  {
48  $legacyFormatters = array(
49  'scss_formatter' => 'Leafo\ScssPhp\Formatter\Expanded',
50  'scss_formatter_nested' => 'Leafo\ScssPhp\Formatter\Nested',
51  'scss_formatter_compressed' => 'Leafo\ScssPhp\Formatter\Compressed',
52  'scss_formatter_crunched' => 'Leafo\ScssPhp\Formatter\Crunched',
53  );
54 
55  if (isset($legacyFormatters[$formatter])) {
56  @trigger_error(sprintf('The scssphp formatter `%s` is deprecated. Use `%s` instead.', $formatter, $legacyFormatters[$formatter]), E_USER_DEPRECATED);
57 
58  $formatter = $legacyFormatters[$formatter];
59  }
60 
61  $this->formatter = $formatter;
62  }
Create styles array
The data for the language used.

◆ setImportPaths()

Assetic\Filter\ScssphpFilter::setImportPaths ( array  $paths)

Definition at line 74 of file ScssphpFilter.php.

75  {
76  $this->importPaths = $paths;
77  }

◆ setVariables()

Assetic\Filter\ScssphpFilter::setVariables ( array  $variables)

Definition at line 64 of file ScssphpFilter.php.

References Assetic\Filter\ScssphpFilter\$variables.

65  {
66  $this->variables = $variables;
67  }

Field Documentation

◆ $compass

Assetic\Filter\ScssphpFilter::$compass = false
private

Definition at line 30 of file ScssphpFilter.php.

Referenced by Assetic\Filter\ScssphpFilter\isCompassEnabled().

◆ $customFunctions

Assetic\Filter\ScssphpFilter::$customFunctions = array()
private

Definition at line 32 of file ScssphpFilter.php.

◆ $formatter

Assetic\Filter\ScssphpFilter::$formatter
private

Definition at line 33 of file ScssphpFilter.php.

Referenced by Assetic\Filter\ScssphpFilter\setFormatter().

◆ $importPaths

Assetic\Filter\ScssphpFilter::$importPaths = array()
private

Definition at line 31 of file ScssphpFilter.php.

◆ $variables

Assetic\Filter\ScssphpFilter::$variables = array()
private

Definition at line 34 of file ScssphpFilter.php.

Referenced by Assetic\Filter\ScssphpFilter\setVariables().


The documentation for this class was generated from the following file: