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


PHP AssetInterface::getSourceRoot方法代码示例

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


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

示例1: filterLoad

 /**
  * Filters an asset after it has been loaded.
  *
  * @param  \Assetic\Asset\AssetInterface  $asset
  * @return void
  */
 public function filterLoad(AssetInterface $asset)
 {
     $max_nesting_level = ini_get('xdebug.max_nesting_level');
     $memory_limit = ini_get('memory_limit');
     if ($max_nesting_level && $max_nesting_level < 200) {
         ini_set('xdebug.max_nesting_level', 200);
     }
     if ($memory_limit && $memory_limit < 256) {
         ini_set('memory_limit', '256M');
     }
     $root = $asset->getSourceRoot();
     $path = $asset->getSourcePath();
     $dirs = array();
     $lc = new \Less_Parser(array('compress' => true));
     if ($root && $path) {
         $dirs[] = dirname($root . '/' . $path);
     }
     foreach ($this->loadPaths as $loadPath) {
         $dirs[] = $loadPath;
     }
     $lc->SetImportDirs($dirs);
     $url = parse_url($this->getRequest()->getUriForPath(''));
     $absolutePath = str_replace(public_path(), '', $root);
     if (isset($url['path'])) {
         $absolutePath = $url['path'] . $absolutePath;
     }
     $lc->parseFile($root . '/' . $path, $absolutePath);
     $asset->setContent($lc->getCss());
 }
开发者ID:cartalyst,项目名称:assetic-filters,代码行数:35,代码来源:LessphpFilter.php

示例2: filterLoad

 /**
  * 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);
 }
开发者ID:spoonx,项目名称:sxbootstrap,代码行数:30,代码来源:BootstrapFilter.php

示例3: resolveUrl

 /**
  * Resolves an URL from an asset.
  *
  * @param AssetInterface $asset the asset containing the URL
  * @param string         $url   url read in file
  *
  * @return string an URL, a filepath
  */
 public static function resolveUrl(AssetInterface $asset, $url)
 {
     // given URL is absolute URL
     if (false !== strpos($url, '://')) {
         return $url;
     }
     // source directory of the asset
     $root = dirname($asset->getSourceRoot() . '/' . $asset->getTargetPath());
     // path directory where asset is being copied
     $path = dirname($asset->getTargetPath());
     if ('.' === $path) {
         $image = $url;
     } else {
         $image = $path . '/' . $url;
     }
     if (null !== $root) {
         $image = $root . '/' . $url;
     }
     // cleanup local URLs
     if (false === strpos($image, '://')) {
         $image = self::removeQueryString($image);
         $image = self::removeAnchor($image);
         return self::resolveUps($image);
     }
     return $image;
 }
开发者ID:alexandresalome,项目名称:assetic-extra-bundle,代码行数:34,代码来源:PathUtils.php

示例4: filterDump

 public function filterDump(AssetInterface $asset)
 {
     $content = "";
     $files = array();
     $extraFiles = array();
     $absolutePath = $asset->getSourceRoot() . '/' . $asset->getSourcePath();
     $this->parser->mime = $this->parser->mimeType($absolutePath);
     if ($this->parser->mime === 'javascripts') {
         $extraFiles = $this->parser->get("javascript_files", array());
     }
     if ($this->parser->mime === 'stylesheets') {
         $extraFiles = $this->parser->get("stylesheet_files", array());
     }
     $absoluteFilePaths = $this->parser->getFilesArrayFromDirectives($absolutePath);
     if ($absoluteFilePaths) {
         $absoluteFilePaths = $extraFiles + $absoluteFilePaths;
     }
     foreach ($absoluteFilePaths as $absoluteFilePath) {
         $files[] = $this->generator->file($absoluteFilePath, false);
     }
     if (!$absoluteFilePaths) {
         $files[] = $this->generator->file($absolutePath, false);
     }
     $global_filters = $this->parser->get("sprockets_filters.{$this->parser->mime}", array());
     $collection = new AssetCollection($files, $global_filters);
     $asset->setContent($collection->dump());
 }
开发者ID:yashb,项目名称:generator,代码行数:27,代码来源:SprocketsFilter.php

示例5: filterDump

 /**
  * @param AssetInterface $asset
  */
 public function filterDump(AssetInterface $asset)
 {
     $sourceBase = $asset->getSourceRoot();
     $sourcePath = $asset->getSourcePath();
     $assetRoot = $this->assetRoot;
     if (null === $sourcePath) {
         return;
     }
     $content = $this->filterReferences($asset->getContent(), function ($matches) use($sourceBase, $sourcePath, $assetRoot) {
         // its not a relative path
         if (false !== strpos($matches['url'], '://') || 0 === strpos($matches['url'], '//') || 0 === strpos($matches['url'], 'data:') || isset($matches['url'][0]) && '/' == $matches['url'][0]) {
             return $matches[0];
         }
         $url = $matches['url'];
         if (false !== ($pos = strpos($url, '?'))) {
             $url = substr($url, 0, $pos);
         }
         $sourceAsset = dirname($sourceBase . '/' . $sourcePath) . '/' . $url;
         if (!is_file($sourceAsset)) {
             return $matches[0];
         }
         $mimeType = MimeTypeGuesser::getInstance()->guess($sourceAsset);
         $destRelativePath = substr($mimeType, 0, strpos($mimeType, '/')) . '/' . basename($url);
         $destAsset = $assetRoot . '/' . $destRelativePath;
         if (!is_dir(dirname($destAsset))) {
             mkdir(dirname($destAsset), 0777, true);
         }
         copy($sourceAsset, $destAsset);
         return str_replace($matches['url'], '../' . $destRelativePath, $matches[0]);
     });
     $asset->setContent($content);
 }
开发者ID:saxulum,项目名称:saxulum-assetic-twig-provider,代码行数:35,代码来源:CssCopyFileFilter.php

示例6: doDump

 /**
  * Performs the asset dump.
  *
  * @param AssetInterface  $asset  An asset
  * @param OutputInterface $stdout The command output
  *
  * @throws RuntimeException If there is a problem writing the asset
  */
 private function doDump(AssetInterface $asset, OutputInterface $stdout)
 {
     $combinations = VarUtils::getCombinations($asset->getVars(), $this->getContainer()->getParameter('assetic.variables'));
     foreach ($combinations as $combination) {
         $asset->setValues($combination);
         // resolve the target path
         $target = rtrim($this->basePath, '/') . '/' . $asset->getTargetPath();
         $target = str_replace('_controller/', '', $target);
         $target = VarUtils::resolve($target, $asset->getVars(), $asset->getValues());
         if (!is_dir($dir = dirname($target))) {
             $stdout->writeln(sprintf('<comment>%s</comment> <info>[dir+]</info> %s', date('H:i:s'), $dir));
             if (false === @mkdir($dir, 0777, true)) {
                 throw new \RuntimeException('Unable to create directory ' . $dir);
             }
         }
         $stdout->writeln(sprintf('<comment>%s</comment> <info>[file+]</info> %s', date('H:i:s'), $target));
         if (OutputInterface::VERBOSITY_VERBOSE <= $stdout->getVerbosity()) {
             if ($asset instanceof AssetCollectionInterface) {
                 foreach ($asset as $leaf) {
                     $root = $leaf->getSourceRoot();
                     $path = $leaf->getSourcePath();
                     $stdout->writeln(sprintf('        <comment>%s/%s</comment>', $root ?: '[unknown root]', $path ?: '[unknown path]'));
                 }
             } else {
                 $root = $asset->getSourceRoot();
                 $path = $asset->getSourcePath();
                 $stdout->writeln(sprintf('        <comment>%s/%s</comment>', $root ?: '[unknown root]', $path ?: '[unknown path]'));
             }
         }
         if (false === @file_put_contents($target, $asset->dump())) {
             throw new \RuntimeException('Unable to write file ' . $target);
         }
     }
 }
开发者ID:fotomerchant,项目名称:AsseticBundle,代码行数:42,代码来源:AbstractCommand.php

示例7: hashAsset

 /**
  * Update a given hash with the sha1 hash of an individual asset
  *
  * @param AssetInterface $asset
  * @param $hash
  */
 protected function hashAsset(AssetInterface $asset, $hash)
 {
     $sourcePath = $asset->getSourcePath();
     $sourceRoot = $asset->getSourceRoot();
     $data = $sourcePath && $sourceRoot && file_exists($sourceRoot . "/" . $sourcePath) ? hash_file('sha1', $sourceRoot . "/" . $sourcePath) : $sourcePath;
     hash_update($hash, $data);
 }
开发者ID:course-hero,项目名称:assetic-filehash-buster,代码行数:13,代码来源:FilehashCacheBustingWorker.php

示例8: filterLoad

 public function filterLoad(AssetInterface $asset)
 {
     $parser = new Less_Parser();
     // CSS Rewriter will take care of this
     $parser->SetOption('relativeUrls', false);
     $parser->parseFile($asset->getSourceRoot() . '/' . $asset->getSourcePath());
     $asset->setContent($parser->getCss());
 }
开发者ID:brenodouglas,项目名称:library,代码行数:8,代码来源:LessCompiler.php

示例9: filterDump

 public function filterDump(AssetInterface $asset)
 {
     $this->root = $asset->getSourceRoot() . '/';
     $this->file = $asset->getSourcePath();
     $this->base = $this->getRelativePath($this->paths, $this->root);
     $content = $this->filterReferences($asset->getContent(), array($this, 'url_matcher'));
     $asset->setContent($content);
 }
开发者ID:codesleeve,项目名称:asset-pipeline,代码行数:8,代码来源:URLRewrite.php

示例10: filterDump

 public function filterDump(AssetInterface $asset)
 {
     $sourceBase = $asset->getSourceRoot();
     $sourcePath = $asset->getSourcePath();
     $targetPath = $asset->getTargetPath();
     if (null === $sourcePath || null === $targetPath || $sourcePath == $targetPath) {
         return;
     }
     // learn how to get from the target back to the source
     if (false !== strpos($sourceBase, '://')) {
         list($scheme, $url) = explode('://', $sourceBase . '/' . $sourcePath, 2);
         list($host, $path) = explode('/', $url, 2);
         $host = $scheme . '://' . $host . '/';
         $path = false === strpos($path, '/') ? '' : dirname($path);
         $path .= '/';
     } else {
         // assume source and target are on the same host
         $host = '';
         // pop entries off the target until it fits in the source
         if ('.' == dirname($sourcePath)) {
             $path = str_repeat('../', substr_count($targetPath, '/'));
         } elseif ('.' == ($targetDir = dirname($targetPath))) {
             $path = dirname($sourcePath) . '/';
         } else {
             while (0 !== strpos($sourcePath, $targetDir)) {
                 if (false !== ($pos = strrpos($targetDir, '/'))) {
                     $targetDir = substr($targetDir, 0, $pos);
                 } else {
                     $targetDir = '';
                     break;
                 }
             }
             $path = '/';
             $path .= ltrim(substr(dirname($sourcePath) . '/', strlen($targetDir)), '/');
         }
     }
     $content = $this->filterReferences($asset->getContent(), function ($matches) use($host, $path) {
         if (false !== strpos($matches['url'], '://') || 0 === strpos($matches['url'], '//') || 0 === strpos($matches['url'], 'data:')) {
             // absolute or protocol-relative or data uri
             return $matches[0];
         }
         if ('/' == $matches['url'][0]) {
             // root relative
             return str_replace($matches['url'], $host . $matches['url'], $matches[0]);
         }
         // document relative
         $url = $matches['url'];
         $parts = array();
         foreach (explode('/', $host . $path . $url) as $part) {
             if ('..' === $part && count($parts) && '..' !== end($parts)) {
                 array_pop($parts);
             }
             $parts[] = $part;
         }
         return str_replace($matches['url'], implode('/', $parts), $matches[0]);
     });
     $asset->setContent($content);
 }
开发者ID:mylen,项目名称:jquery-file-upload-bundle,代码行数:58,代码来源:CssRewriteFilter.php

示例11: filterLoad

 public function filterLoad(AssetInterface $asset)
 {
     $importFilter = $this->importFilter;
     $sourceRoot = $asset->getSourceRoot();
     $sourcePath = $asset->getSourcePath();
     $callback = function ($matches) use($importFilter, $sourceRoot, $sourcePath) {
         if (!$matches['url']) {
             return $matches[0];
         }
         if (null === $sourceRoot) {
             return $matches[0];
         }
         $importRoot = $sourceRoot;
         if (false !== strpos($matches['url'], '://')) {
             // absolute
             list($importScheme, $tmp) = explode('://', $matches['url'], 2);
             list($importHost, $importPath) = explode('/', $tmp, 2);
             $importRoot = $importScheme . '://' . $importHost;
         } elseif (0 === strpos($matches['url'], '//')) {
             // protocol-relative
             list($importHost, $importPath) = explode('/', substr($matches['url'], 2), 2);
             $importHost = '//' . $importHost;
         } elseif ('/' == $matches['url'][0]) {
             // root-relative
             $importPath = substr($matches['url'], 1);
         } elseif (null !== $sourcePath) {
             // document-relative
             $importPath = $matches['url'];
             if ('.' != ($sourceDir = dirname($sourcePath))) {
                 $importPath = $sourceDir . '/' . $importPath;
             }
         } else {
             return $matches[0];
         }
         // ignore other imports
         if ('css' != pathinfo($importPath, PATHINFO_EXTENSION)) {
             return $matches[0];
         }
         $importSource = $importRoot . '/' . $importPath;
         if (false !== strpos($importSource, '://') || 0 === strpos($importSource, '//')) {
             $import = new HttpAsset($importSource, array($importFilter), true);
         } elseif (!file_exists($importSource)) {
             // ignore not found imports
             return $matches[0];
         } else {
             $import = new FileAsset($importSource, array($importFilter), $importRoot, $importPath);
         }
         $import->setTargetPath($sourcePath);
         return $import->dump();
     };
     $content = $asset->getContent();
     $lastHash = md5($content);
     do {
         $content = $this->filterImports($content, $callback);
         $hash = md5($content);
     } while ($lastHash != $hash && ($lastHash = $hash));
     $asset->setContent($content);
 }
开发者ID:laiello,项目名称:mediathequescrum,代码行数:58,代码来源:CssImportFilter.php

示例12: filterLoad

 /**
  * Filters an asset after it has been loaded.
  *
  * @param AssetInterface $asset An asset
  */
 public function filterLoad(AssetInterface $asset)
 {
     $parser = clone $this->parser;
     $parser->SetOptions($this->options);
     if ($this->str_endswith($asset->getSourcePath(), ['.less'])) {
         $parser->parseFile($asset->getSourceRoot() . DIRECTORY_SEPARATOR . $asset->getSourcePath());
         $asset->setContent($parser->getCss());
     }
 }
开发者ID:zae,项目名称:larattic,代码行数:14,代码来源:LessFilter.php

示例13: getSourceRoot

 /**
  * {@inheritdoc}
  */
 public function getSourceRoot()
 {
     if ($this->innerAsset) {
         return $this->innerAsset->getSourceRoot();
     }
     // Not accurate, but this method is called by AssetCollectionIterator
     // before setValues() is called, so we need to return something
     return null;
 }
开发者ID:puli,项目名称:assetic-extension,代码行数:12,代码来源:LazyAsset.php

示例14: filterLoad

 public function filterLoad(AssetInterface $asset)
 {
     $options = array($this->sassPath);
     $root = $asset->getSourceRoot();
     $path = $asset->getSourcePath();
     if ($root && $path) {
         $options[] = '--load-path';
         $options[] = dirname($root . '/' . $path);
     }
     if ($this->unixNewlines) {
         $options[] = '--unix-newlines';
     }
     if (true === $this->scss || null === $this->scss && 'scss' == pathinfo($path, PATHINFO_EXTENSION)) {
         $options[] = '--scss';
     }
     if ($this->style) {
         $options[] = '--style';
         $options[] = $this->style;
     }
     if ($this->quiet) {
         $options[] = '--quiet';
     }
     if ($this->debugInfo) {
         $options[] = '--debug-info';
     }
     if ($this->lineNumbers) {
         $options[] = '--line-numbers';
     }
     foreach ($this->loadPaths as $loadPath) {
         $options[] = '--load-path';
         $options[] = $loadPath;
     }
     if ($this->cacheLocation) {
         $options[] = '--cache-location';
         $options[] = $this->cacheLocation;
     }
     if ($this->noCache) {
         $options[] = '--no-cache';
     }
     if ($this->compass) {
         $options[] = '--compass';
     }
     // input
     $options[] = $input = tempnam(sys_get_temp_dir(), 'assetic_sass');
     file_put_contents($input, $asset->getContent());
     // output
     $options[] = $output = tempnam(sys_get_temp_dir(), 'assetic_sass');
     $proc = new Process(implode(' ', array_map('escapeshellarg', $options)));
     $code = $proc->run();
     if (0 < $code) {
         unlink($input);
         throw new \RuntimeException($proc->getErrorOutput());
     }
     $asset->setContent(file_get_contents($output));
     unlink($input);
     unlink($output);
 }
开发者ID:rfc1483,项目名称:symfony,代码行数:57,代码来源:SassFilter.php

示例15: filterLoad

 /**
  * Filters an asset after it has been loaded.
  *
  * @param AssetInterface $asset An asset
  */
 public function filterLoad(AssetInterface $asset)
 {
     if ($this->str_endswith($asset->getSourcePath(), ['.less'])) {
         $file = Less_Cache::Get([$asset->getSourceRoot() . DIRECTORY_SEPARATOR . $asset->getSourcePath() => '/'], $this->options);
         if (is_readable($this->options['cache_dir'] . DIRECTORY_SEPARATOR . $file)) {
             $asset->setContent(file_get_contents($this->options['cache_dir'] . DIRECTORY_SEPARATOR . $file));
         }
     }
 }
开发者ID:zae,项目名称:larattic,代码行数:14,代码来源:LessCacheFilter.php


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