/**
  * {@inheritDoc}
  */
 public function registerFor(FilterInterface $filter)
 {
     $functions = array('asset-url' => 'assetUrl', 'asset-path' => 'assetPath', 'core-asset-url' => 'coreAssetUrl', 'core-asset-path' => 'coreAssetPath', 'theme-asset-url' => 'themeAssetUrl', 'theme-asset-path' => 'themeAssetPath', 'package-asset-url' => 'packageAssetUrl', 'package-asset-path' => 'packageAssetPath');
     foreach ($functions as $sassFunc => $func) {
         $filter->registerFunction($sassFunc, array($this, $func));
     }
 }
Esempio n. 2
0
 /**
  * Sets the by-config generated imports on the asset.
  *
  * {@inheritDoc}
  */
 public function filterLoad(AssetInterface $asset)
 {
     $assetRoot = $asset->getSourceRoot();
     $assetPath = $asset->getSourcePath();
     $assetImportDir = dirname($assetRoot . '/' . $assetPath);
     $importDir = $this->config->getBootstrapPath() . '/less';
     $this->setupLoadPaths($assetImportDir);
     // Make sure we _always_ have the bootstrap import dir.
     if ($importDir !== $assetImportDir) {
         $this->lessFilter->addLoadPath($importDir);
     }
     $variables = array_merge($this->extractVariables($importDir . '/variables.less'), $this->config->getVariables());
     $variablesString = '';
     foreach ($variables as $key => $value) {
         $variablesString .= "@{$key}:{$value};" . PHP_EOL;
     }
     if ('bootstrap.less' === $assetPath) {
         $imports = $this->filterImportFiles(array_unique(array_merge($this->extractImports($importDir . '/bootstrap.less'), $this->extractImports($importDir . '/responsive.less'), $this->config->getCustomComponents())));
         $assetContent = $variablesString . $imports;
         $asset->setContent($assetContent);
     } else {
         $asset->setContent($variablesString . $asset->getContent());
     }
     $this->lessFilter->filterLoad($asset);
 }