当前位置: 首页>>代码示例>>PHP>>正文


PHP AssetInterface::getSourceDirectory方法代码示例

本文整理汇总了PHP中Assetic\Asset\AssetInterface::getSourceDirectory方法的典型用法代码示例。如果您正苦于以下问题:PHP AssetInterface::getSourceDirectory方法的具体用法?PHP AssetInterface::getSourceDirectory怎么用?PHP AssetInterface::getSourceDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Assetic\Asset\AssetInterface的用法示例。


在下文中一共展示了AssetInterface::getSourceDirectory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: filterDump

 /**
  * Apply a filter on file dump.
  *
  * @param  \Assetic\Asset\AssetInterface  $asset
  * @return void
  */
 public function filterDump(AssetInterface $asset)
 {
     // Using getSourceDirectory
     // instead of getSourceRoot
     // Since relative paths are based on the sourceDirectory...
     $this->assetDirectory = $this->realPath($asset->getSourceDirectory());
     $content = $asset->getContent();
     // Spin through the symlinks and normalize them. We'll first unset the original
     // symlink so that it doesn't clash with the new symlinks once they are added
     // back in.
     foreach ($this->symlinks as $link => $target) {
         unset($this->symlinks[$link]);
         if ($link == '//') {
             $link = $this->documentRoot;
         } else {
             $link = str_replace('//', $this->documentRoot . '/', $link);
         }
         $link = strtr($link, '/', DIRECTORY_SEPARATOR);
         $this->symlinks[$link] = $this->realPath($target);
     }
     $content = $this->trimUrls($content);
     $content = preg_replace_callback('/@import\\s+([\'"])(.*?)[\'"]/', array($this, 'processUriCallback'), $content);
     $content = preg_replace_callback('/url\\(\\s*([^\\)\\s]+)\\s*\\)/', array($this, 'processUriCallback'), $content);
     $asset->setContent($content);
 }
开发者ID:dustingraham,项目名称:asset-manager,代码行数:31,代码来源:AssetCssUriRewriteFilter.php

示例2: filterLoad

 public function filterLoad(AssetInterface $asset)
 {
     $sassProcessArgs = array();
     if (null !== $this->nodePath) {
         $sassProcessArgs[] = $this->nodePath;
     }
     $sassProcessArgs[] = $this->sassPath;
     $pb = $this->createProcessBuilder($sassProcessArgs);
     if ($dir = $asset->getSourceDirectory()) {
         $pb->add('--include-path')->add($dir);
     }
     if ($this->style) {
         $pb->add('--output-style')->add($this->style);
     }
     if ($this->sourceMap) {
         $pb->add('--source-map');
     }
     if ($this->debugInfo) {
         $pb->add('--source-comments');
     }
     foreach ($this->loadPaths as $loadPath) {
         $pb->add('--include-path')->add($loadPath);
     }
     // input
     $pb->add($input = tempnam(sys_get_temp_dir(), 'assetic_sass'));
     file_put_contents($input, $asset->getContent());
     $pb->add('--stdout');
     $proc = $pb->getProcess();
     $code = $proc->run();
     unlink($input);
     if (0 !== $code) {
         throw FilterException::fromProcess($proc)->setInput($asset->getContent());
     }
     $asset->setContent($proc->getOutput());
 }
开发者ID:elmariachi111,项目名称:node-sass-bundle,代码行数:35,代码来源:NodeSassFilter.php

示例3: getSourceDirectory

 /**
  * {@inheritdoc}
  */
 public function getSourceDirectory()
 {
     if (!$this->innerAsset) {
         $this->createInnerAsset();
     }
     return $this->innerAsset->getSourceDirectory();
 }
开发者ID:puli,项目名称:assetic-extension,代码行数:10,代码来源:LazyAsset.php

示例4: filterLoad

 public function filterLoad(AssetInterface $asset)
 {
     $pce = new CssEmbed();
     if ($dir = $asset->getSourceDirectory()) {
         $pce->setRootDir($dir);
     }
     $asset->setContent($pce->embedString($asset->getContent()));
 }
开发者ID:BusinessCookies,项目名称:CoffeeMachineProject,代码行数:8,代码来源:PhpCssEmbedFilter.php

示例5: filterDump

 /**
  * Filters an asset just before it's dumped.
  *
  * @param AssetInterface $asset
  */
 public function filterDump(AssetInterface $asset)
 {
     $this->dispatch(new LoadThemeVariables($variables = new Collection()));
     $compiler = new Compiler();
     if ($dir = $asset->getSourceDirectory()) {
         $compiler->addImportPath($dir);
     }
     $compiler->setVariables($variables->all());
     $asset->setContent($this->parser->parse($compiler->compile($asset->getContent())));
 }
开发者ID:huglester,项目名称:streams-platform,代码行数:15,代码来源:ScssFilter.php

示例6: filterLoad

 public function filterLoad(AssetInterface $asset)
 {
     $sass = new \Sass();
     $includePaths = array_merge(array($asset->getSourceDirectory()), $this->includePaths);
     $sass->setIncludePath(implode(':', $includePaths));
     if ($this->outputStyle) {
         $sass->setStyle($this->outputStyle);
     }
     $css = $sass->compile($asset->getContent());
     $asset->setContent($css);
 }
开发者ID:theaxel,项目名称:assetic,代码行数:11,代码来源:SassphpFilter.php

示例7: filterDump

 public function filterDump(AssetInterface $asset)
 {
     $filters = $this->filters;
     $plugins = $this->plugins;
     if (isset($filters['ImportImports']) && true === $filters['ImportImports']) {
         if ($dir = $asset->getSourceDirectory()) {
             $filters['ImportImports'] = array('BasePath' => $dir);
         } else {
             unset($filters['ImportImports']);
         }
     }
     $asset->setContent(\CssMin::minify($asset->getContent(), $filters, $plugins));
 }
开发者ID:jackycgq,项目名称:bzfshop,代码行数:13,代码来源:CssMinFilter.php

示例8: filterDump

 /**
  * Filters an asset just before it's dumped.
  *
  * @param AssetInterface $asset
  */
 public function filterDump(AssetInterface $asset)
 {
     $compiler = new \lessc();
     $this->dispatch(new LoadThemeVariables($variables = new Collection()));
     $compiler->setVariables($variables->all());
     if ($dir = $asset->getSourceDirectory()) {
         $compiler->importDir = $dir;
     }
     foreach ($this->loadPaths as $loadPath) {
         $compiler->addImportDir($loadPath);
     }
     $asset->setContent($compiler->parse($this->parser->parse($asset->getContent())));
 }
开发者ID:huglester,项目名称:streams-platform,代码行数:18,代码来源:LessFilter.php

示例9: filterLoad

 public function filterLoad(AssetInterface $asset)
 {
     $lc = new \scssc();
     if ($this->compass) {
         new \scss_compass($lc);
     }
     if ($dir = $asset->getSourceDirectory()) {
         $lc->addImportPath($dir);
     }
     foreach ($this->importPaths as $path) {
         $lc->addImportPath($path);
     }
     $asset->setContent($lc->compile($asset->getContent()));
 }
开发者ID:2329697501,项目名称:CI_Assetic,代码行数:14,代码来源:ScssphpFilter.php

示例10: filterLoad

 public function filterLoad(AssetInterface $asset)
 {
     $source = $asset->getSourceDirectory() . path('ds') . $asset->getSourcePath();
     $sourceHash = sha1($source . filemtime($source));
     $input = path('tmp') . $sourceHash . '.less.tmp';
     if (!is_file($input)) {
         $content = $asset->getContent();
         /**
          * Fix ../ and similar urls.
          */
         $sourceDir = $asset->getSourceDirectory();
         $rootDir = path('root');
         /**
          * Source dir is always longer than root dir.
          * Dir diff will be prepended to urls.
          */
         $dirDiff = str_replace($rootDir, path('ds'), $sourceDir);
         /**
          * Make replacement.
          */
         $content = preg_replace_callback('/url\\(([\\s])?([\\"|\'])?(.*?)([\\"|\'])?([\\s])?\\)/i', function ($matches) use($sourceDir, $rootDir, $dirDiff) {
             $value = $matches[0];
             /**
              * We have to move $dots times towards root.
              */
             if ($dots = substr_count($value, '../')) {
                 /**
                  * We have to move $dots times towards root.
                  */
                 $resourcePath = realpath($sourceDir . path('ds') . str_repeat('..' . path('ds'), $dots));
                 $relativeDir = str_replace($rootDir, path('ds'), $resourcePath) . path('ds');
                 $urlPart = strpos($value, 'url("') !== false ? 'url("' : (strpos($value, 'url(\'') !== false ? 'url(\'' : 'url(');
                 $value = str_replace($urlPart, $urlPart . $relativeDir, str_replace('../', '', $value));
             }
             /**
              * We have to simply prepend path.
              */
             if (strpos($value, 'url("') !== false && strpos($value, 'url("/)') === false || strpos($value, 'url(\'') !== false && strpos($value, 'url(\'/') === false) {
                 $value = str_replace(['url("', 'url(\''], ['url("' . $dirDiff . '/', 'url(\'' . $dirDiff . '/'], $value);
             }
             return $value;
         }, $content);
     } else {
         $content = file_get_contents($input);
     }
     $asset->setContent($content);
 }
开发者ID:pckg,项目名称:manager,代码行数:47,代码来源:PathPckgFilter.php

示例11: filterLoad

 public function filterLoad(AssetInterface $asset)
 {
     $sc = new \scssc();
     if ($this->compass) {
         new \scss_compass($sc);
     }
     if ($dir = $asset->getSourceDirectory()) {
         $sc->addImportPath($dir);
     }
     foreach ($this->importPaths as $path) {
         $sc->addImportPath($path);
     }
     foreach ($this->customFunctions as $name => $callable) {
         $sc->registerFunction($name, $callable);
     }
     $asset->setContent($sc->compile($asset->getContent()));
 }
开发者ID:Kevin-ZK,项目名称:vaneDisk,代码行数:17,代码来源:ScssphpFilter.php

示例12: filterLoad

 public function filterLoad(AssetInterface $asset)
 {
     $lc = new \lessc();
     if ($dir = $asset->getSourceDirectory()) {
         $lc->importDir = $dir;
     }
     foreach ($this->loadPaths as $loadPath) {
         $lc->addImportDir($loadPath);
     }
     if ($this->formatter) {
         $lc->setFormatter($this->formatter);
     }
     if (null !== $this->preserveComments) {
         $lc->setPreserveComments($this->preserveComments);
     }
     $asset->setContent($lc->parse($asset->getContent(), $this->presets));
 }
开发者ID:samj1912,项目名称:repo,代码行数:17,代码来源:LessphpFilter.php

示例13: filterLoad

 public function filterLoad(AssetInterface $asset)
 {
     $filePath = $asset->getSourceRoot() . DS . $asset->getSourcePath();
     Tlog::getInstance()->addDebug("Starting CSS processing: {$filePath}...");
     $importDirs = [];
     if ($dir = $asset->getSourceDirectory()) {
         $importDirs[$dir] = '';
     }
     foreach ($this->loadPaths as $loadPath) {
         $importDirs[$loadPath] = '';
     }
     $options = ['cache_dir' => $this->cacheDir, 'relativeUrls' => false, 'compress' => true, 'import_dirs' => $importDirs];
     $css_file_name = \Less_Cache::Get([$filePath => ''], $options);
     $content = @file_get_contents($this->cacheDir . DS . $css_file_name);
     if ($content === false) {
         $content = '';
         Tlog::getInstance()->warning("Compilation of {$filePath} did not generate an output file.");
     }
     $asset->setContent($content);
     Tlog::getInstance()->addDebug("CSS processing done.");
 }
开发者ID:margery,项目名称:thelia,代码行数:21,代码来源:LessDotPhpFilter.php

示例14: filterLoad

 public function filterLoad(AssetInterface $asset)
 {
     $lc = new \lessc();
     if ($dir = $asset->getSourceDirectory()) {
         $lc->importDir = $dir;
     }
     foreach ($this->loadPaths as $loadPath) {
         $lc->addImportDir($loadPath);
     }
     foreach ($this->customFunctions as $name => $callable) {
         $lc->registerFunction($name, $callable);
     }
     if ($this->formatter) {
         $lc->setFormatter($this->formatter);
     }
     if (null !== $this->preserveComments) {
         $lc->setPreserveComments($this->preserveComments);
     }
     if (method_exists($lc, 'setOptions') && count($this->options) > 0) {
         $lc->setOptions($this->options);
     }
     $asset->setContent($lc->parse($asset->getContent(), $this->presets));
 }
开发者ID:Dren-x,项目名称:mobit,代码行数:23,代码来源:LessphpFilter.php

示例15: filterLoad

    /**
     * {@inheritdoc}
     */
    public function filterLoad(AssetInterface $asset)
    {
        static $format = <<<'EOF'
var stylus = require('stylus');
var sys    = require(process.binding('natives').util ? 'util' : 'sys');

stylus(%s, %s)%s.render(function(e, css){
    if (e) {
        throw e;
    }

    sys.print(css);
    process.exit(0);
});

EOF;
        // parser options
        $parserOptions = array();
        if ($dir = $asset->getSourceDirectory()) {
            $parserOptions['paths'] = array($dir);
            $parserOptions['filename'] = basename($asset->getSourcePath());
        }
        if (null !== $this->compress) {
            $parserOptions['compress'] = $this->compress;
        }
        $pb = $this->createProcessBuilder();
        $pb->add($this->nodeBin)->add($input = FilesystemUtils::createTemporaryFile('stylus'));
        file_put_contents($input, sprintf($format, json_encode($asset->getContent()), json_encode($parserOptions), $this->useNib ? '.use(require(\'nib\')())' : ''));
        $proc = $pb->getProcess();
        $code = $proc->run();
        unlink($input);
        if (0 !== $code) {
            throw FilterException::fromProcess($proc)->setInput($asset->getContent());
        }
        $asset->setContent($proc->getOutput());
    }
开发者ID:BusinessCookies,项目名称:CoffeeMachineProject,代码行数:39,代码来源:StylusFilter.php


注:本文中的Assetic\Asset\AssetInterface::getSourceDirectory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。