當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。