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


PHP AssetInterface::getTargetPath方法代码示例

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


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

示例1: 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

示例2: getAssetUrl

 protected function getAssetUrl(AssetInterface $asset, $options = array())
 {
     $package = isset($options['package']) ? $options['package'] : null;
     if (null === $this->packages) {
         return $this->assetsHelper->getUrl($asset->getTargetPath(), $package);
     }
     return $this->packages->getPackage($package)->getUrl($asset->getTargetPath());
 }
开发者ID:BusinessCookies,项目名称:CoffeeMachineProject,代码行数:8,代码来源:StaticAsseticHelper.php

示例3: compileAssetUrl

 private function compileAssetUrl(\Twig_Compiler $compiler, AssetInterface $asset)
 {
     $compiler->repr($asset->getTargetPath());
     if (file_exists(PUB_DIR . DS . $asset->getTargetPath())) {
         return;
     }
     $writer = new \Assetic\AssetWriter(PUB_DIR . DS);
     $writer->writeAsset($asset);
 }
开发者ID:hidekscorporation,项目名称:hideksframework2,代码行数:9,代码来源:AsseticNode.php

示例4: filterDump

 /**
  * {@inheritdoc}
  */
 public function filterDump(AssetInterface $asset)
 {
     $webDir = $this->webDir;
     $isController = 0 === strpos($asset->getTargetPath(), '_controller/');
     $target = PathUtils::normalizePath($this->webDir . '/' . str_replace('_controller/', '', $asset->getTargetPath()));
     $source = PathUtils::normalizePath($asset->getSourceRoot() . '/' . $asset->getSourcePath());
     $content = $this->filterReferences($asset->getContent(), function ($matches) use($isController, $source, $target, $webDir) {
         if (file_exists($webDir . '/' . $matches['url'])) {
             return str_replace($matches['url'], PathUtils::findShortestPath($target, $webDir . '/' . $matches['url'], $isController), $matches[0]);
         }
         return $matches[0];
     });
     $asset->setContent($content);
 }
开发者ID:webuni,项目名称:assetic-bundle,代码行数:17,代码来源:CssWebRewriteFilter.php

示例5: __construct

 /**
  * @param AssetInterface $asset
  * @param AssetWriter $writer
  * @param array $cachePath
  * @param array $headers
  */
 public function __construct(AssetInterface $asset, AssetWriter $writer, $cachePath, array $headers = [])
 {
     $file = $asset->getTargetPath();
     $cachePath = $cachePath . '/' . $file;
     $cached = false;
     $cacheTime = time();
     if (is_file($cachePath)) {
         $mTime = $asset->getLastModified();
         $cacheTime = filemtime($cachePath);
         if ($mTime > $cacheTime) {
             @unlink($cachePath);
             $cacheTime = $mTime;
         } else {
             $cached = true;
         }
     }
     if (!$cached) {
         $writer->writeAsset($asset);
     }
     $stream = function () use($cachePath) {
         readfile($cachePath);
     };
     $headers['Content-Length'] = filesize($cachePath);
     if (preg_match('/.+\\.([a-zA-Z0-9]+)/', $file, $matches)) {
         $ext = $matches[1];
         if (isset($this->mimeTypes[$ext])) {
             $headers['Content-Type'] = $this->mimeTypes[$ext];
         }
     }
     parent::__construct($stream, 200, $headers);
     $date = new \DateTime();
     $date->setTimestamp($cacheTime);
     $this->setLastModified($date);
 }
开发者ID:mikegibson,项目名称:sentient,代码行数:40,代码来源:AssetResponse.php

示例6: process

 public function process(AssetInterface $asset)
 {
     $hash = hash_init('sha1');
     switch ($this->strategy) {
         case self::STRATEGY_MODIFICATION:
             hash_update($hash, $asset->getLastModified());
             break;
         case self::STRATEGY_CONTENT:
             hash_update($hash, $asset->dump());
             break;
     }
     foreach ($asset as $i => $leaf) {
         if ($sourcePath = $leaf->getSourcePath()) {
             hash_update($hash, $sourcePath);
         } else {
             hash_update($hash, $i);
         }
     }
     $hash = substr(hash_final($hash), 0, 7);
     $url = $asset->getTargetPath();
     $oldExt = pathinfo($url, PATHINFO_EXTENSION);
     $newExt = '-' . $hash . '.' . $oldExt;
     if (!$oldExt || 0 < preg_match('/' . preg_quote($newExt, '/') . '$/', $url)) {
         return;
     }
     $asset->setTargetPath(substr($url, 0, (strlen($oldExt) + 1) * -1) . $newExt);
 }
开发者ID:alexBLR,项目名称:firmware,代码行数:27,代码来源:CacheBustingWorker.php

示例7: getTargetPath

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

示例8: 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

示例9: writeAsset

 public function writeAsset(AssetInterface $asset)
 {
     foreach ($this->getCombinations($asset->getVars()) as $combination) {
         $asset->setValues($combination);
         static::write($this->dir . '/' . PathUtils::resolvePath($asset->getTargetPath(), $asset->getVars(), $asset->getValues()), $asset->dump());
     }
 }
开发者ID:bmavus,项目名称:wp-theme-blank,代码行数:7,代码来源:AssetWriter.php

示例10: process

 public function process(AssetInterface $asset, AssetFactory $factory)
 {
     $targetUrl = $asset->getTargetPath();
     if ($targetUrl && '/' != $targetUrl[0] && 0 !== strpos($targetUrl, '_controller/')) {
         $asset->setTargetPath('_controller/' . $targetUrl);
     }
     return $asset;
 }
开发者ID:BusinessCookies,项目名称:CoffeeMachineProject,代码行数:8,代码来源:UseControllerWorker.php

示例11: 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

示例12: compileAssetUrl

 protected function compileAssetUrl(\Twig_Compiler $compiler, AssetInterface $asset, $name)
 {
     $compiler
         ->raw('isset($context[\'assetic\'][\'use_controller\']) && $context[\'assetic\'][\'use_controller\'] ? ')
         ->subcompile($this->getPathFunction($name))
         ->raw(' : ')
         ->subcompile($this->getAssetFunction($asset->getTargetPath()))
     ;
 }
开发者ID:ndusan,项目名称:tbq,代码行数:9,代码来源:AsseticNode.php

示例13: process

 /**
  * Processes an asset.
  *
  * @param AssetInterface $asset An asset
  *
  * @return AssetInterface|null May optionally return a replacement asset
  */
 public function process(AssetInterface $asset)
 {
     $path = $asset->getTargetPath();
     $ext = pathinfo($path, PATHINFO_EXTENSION);
     $revision = $this->getRevision();
     if (null !== $revision) {
         $path = substr_replace($path, "{$revision}.{$ext}", -1 * strlen($ext));
         $asset->setTargetPath($path);
     }
 }
开发者ID:enlitepro,项目名称:enlite-assetic,代码行数:17,代码来源:Capistrano.php

示例14: writeAsset

 public function writeAsset(AssetInterface $asset)
 {
     foreach (VarUtils::getCombinations($asset->getVars(), $this->values) as $combination) {
         $asset->setValues($combination);
         $path = $this->dir . '/' . VarUtils::resolve($asset->getTargetPath(), $asset->getVars(), $asset->getValues());
         if (!is_dir($path) && (!file_exists($path) || filemtime($path) <= $asset->getLastModified())) {
             static::write($path, $asset->dump());
         }
     }
 }
开发者ID:mohamedsharaf,项目名称:laravel-assetic,代码行数:10,代码来源:CheckedAssetWriter.php

示例15: process

 public function process(AssetInterface $asset, AssetFactory $factory)
 {
     $path = $asset->getTargetPath();
     $ext = pathinfo($path, PATHINFO_EXTENSION);
     $lastModified = $asset->getLastModified();
     if (null !== $lastModified) {
         $path = substr_replace($path, "{$lastModified}.{$ext}", -1 * strlen($ext));
         $asset->setTargetPath($path);
     }
 }
开发者ID:kersten,项目名称:zf2-assetic-module,代码行数:10,代码来源:LastModifiedStrategy.php


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