當前位置: 首頁>>代碼示例>>PHP>>正文


PHP AssetInterface::dump方法代碼示例

本文整理匯總了PHP中Assetic\Asset\AssetInterface::dump方法的典型用法代碼示例。如果您正苦於以下問題:PHP AssetInterface::dump方法的具體用法?PHP AssetInterface::dump怎麽用?PHP AssetInterface::dump使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Assetic\Asset\AssetInterface的用法示例。


在下文中一共展示了AssetInterface::dump方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

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

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

示例3: dump

 /**
  * {@inheritdoc}
  */
 public function dump(FilterInterface $additionalFilter = null)
 {
     if (!$this->innerAsset) {
         $this->createInnerAsset();
     }
     return $this->innerAsset->dump($additionalFilter);
 }
開發者ID:puli,項目名稱:assetic-extension,代碼行數:10,代碼來源:LazyAsset.php

示例4: 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:xilonsolutions,項目名稱:xilon-gaufrette-asset-bundle,代碼行數:42,代碼來源:AbstractCommand.php

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

示例6: dump

 /**
  * Applies dump filters and returns the asset as a string.
  *
  * @param  FilterInterface|null $additionalFilter
  * @return string
  */
 public function dump(FilterInterface $additionalFilter = null)
 {
     $cacheKey = $this->getCacheKey($this->asset, $additionalFilter, 'dump');
     if ($this->cache->has($cacheKey)) {
         return $this->cache->get($cacheKey);
     }
     $content = $this->asset->dump($additionalFilter);
     $this->cache->set($cacheKey, $content);
     return $content;
 }
開發者ID:sunnyct,項目名稱:silexcmf-assetic,代碼行數:16,代碼來源:AssetCache.php

示例7: dumpAsset

 private function dumpAsset(AssetInterface $asset)
 {
     // HTTP caching
     $mtime = gmdate('D, d M y H:i:s', $asset->getLastModified()) . 'GMT';
     if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && ($mtime = $_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
         header('HTTP/1.1 304 Not Modified');
         exit;
     }
     // set headers & dump asset
     $extension = pathinfo($asset->getTargetPath(), PATHINFO_EXTENSION);
     if (array_key_exists($extension, self::$extensionsToMimeTypes)) {
         $mimeType = self::$extensionsToMimeTypes[$extension];
         header("Content-Type: {$mimeType}");
         header("Last-Modified: {$mtime}");
         header('Cache-Control: public');
     }
     echo $asset->dump();
     exit;
 }
開發者ID:tripomatic,項目名稱:nette-assetic,代碼行數:19,代碼來源:AssetRoute.php

示例8: doDump

 private function doDump(AssetInterface $asset, $documentRoot)
 {
     $writer = new AssetWriter(sys_get_temp_dir(), $this->container->getParameter('assetic.variables'));
     $ref = new \ReflectionMethod($writer, 'getCombinations');
     $ref->setAccessible(true);
     $combinations = $ref->invoke($writer, $asset->getVars());
     foreach ($combinations as $combination) {
         $asset->setValues($combination);
         $target = rtrim($documentRoot, '/') . '/' . str_replace('_controller/', '', PathUtils::resolvePath($asset->getTargetPath(), $asset->getVars(), $asset->getValues()));
         if (!is_dir($dir = dirname($target))) {
             if (false === @mkdir($dir, 0777, true)) {
                 throw new \RuntimeException('Unable to create directory ' . $dir);
             }
         }
         if (false === @file_put_contents($target, $asset->dump())) {
             throw new \RuntimeException('Unable to write file ' . $target);
         }
     }
 }
開發者ID:nmariani,項目名稱:AzureDistributionBundle,代碼行數:19,代碼來源:AssetStrategy.php

示例9: doDump

 /**
  * Performs the asset dump.
  *
  * @param AssetInterface  $asset  An asset
  * @param OutputInterface $output The command output
  *
  * @throws RuntimeException If there is a problem writing the asset
  */
 private function doDump(AssetInterface $asset, OutputInterface $output)
 {
     $writer = new AssetWriter(sys_get_temp_dir(), $this->getContainer()->getParameter('assetic.variables'));
     $ref = new \ReflectionMethod($writer, 'getCombinations');
     $ref->setAccessible(true);
     $combinations = $ref->invoke($writer, $asset->getVars());
     foreach ($combinations as $combination) {
         $asset->setValues($combination);
         $target = rtrim($this->basePath, '/') . '/' . str_replace('_controller/', '', PathUtils::resolvePath($asset->getTargetPath(), $asset->getVars(), $asset->getValues()));
         if (!is_dir($dir = dirname($target))) {
             $output->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);
             }
         }
         $output->writeln(sprintf('<comment>%s</comment> <info>[file+]</info> %s', date('H:i:s'), $target));
         if ($this->verbose) {
             if ($asset instanceof \Traversable) {
                 foreach ($asset as $leaf) {
                     $root = $leaf->getSourceRoot();
                     $path = $leaf->getSourcePath();
                     $output->writeln(sprintf('        <comment>%s/%s</comment>', $root ?: '[unknown root]', $path ?: '[unknown path]'));
                 }
             } else {
                 $root = $asset->getSourceRoot();
                 $path = $asset->getSourcePath();
                 $output->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:laubosslink,項目名稱:lab,代碼行數:42,代碼來源:DumpCommand.php

示例10: writeAsset

 public function writeAsset(AssetInterface $asset)
 {
     static::write($this->dir . '/' . $asset->getTargetUrl(), $asset->dump());
 }
開發者ID:nresni,項目名稱:symfony-sandbox,代碼行數:4,代碼來源:AssetWriter.php

示例11: getHash

 /**
  * @param AssetInterface $asset
  * @return string
  */
 private function getHash(AssetInterface $asset)
 {
     return substr(hash($this->algorithm, $asset->dump()), 0, $this->hashLength);
 }
開發者ID:jeroenvdheuvel,項目名稱:assetic-cache-busting-worker,代碼行數:8,代碼來源:CacheBustingWorker.php

示例12: doDump

 /**
  * Performs the asset dump.
  *
  * @param AssetInterface  $asset  An asset
  * @param OutputInterface $output The command output
  *
  * @throws RuntimeException If there is a problem writing the asset
  */
 private function doDump(AssetInterface $asset, OutputInterface $output)
 {
     $target = rtrim($this->basePath, '/') . '/' . str_replace('_controller/', '', $asset->getTargetPath());
     if (!is_dir($dir = dirname($target))) {
         $output->writeln('<info>[dir+]</info>  ' . $dir);
         if (false === @mkdir($dir, 0777, true)) {
             throw new \RuntimeException('Unable to create directory ' . $dir);
         }
     }
     $output->writeln('<info>[file+]</info> ' . $target);
     if ($this->verbose) {
         if ($asset instanceof \Traversable) {
             foreach ($asset as $leaf) {
                 $root = $leaf->getSourceRoot();
                 $path = $leaf->getSourcePath();
                 $output->writeln(sprintf('        <comment>%s/%s</comment>', $root ?: '[unknown root]', $path ?: '[unknown path]'));
             }
         } else {
             $root = $asset->getSourceRoot();
             $path = $asset->getSourcePath();
             $output->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:laiello,項目名稱:mediathequescrum,代碼行數:35,代碼來源:DumpCommand.php

示例13: doDump

 /**
  * Performs the asset dump.
  *
  * @param AssetInterface  $asset  An asset
  * @param OutputInterface $output The command output
  *
  * @throws RuntimeException If there is a problem writing the asset
  */
 private function doDump(AssetInterface $asset, OutputInterface $output)
 {
     $target = rtrim($this->basePath, '/') . '/' . str_replace('_controller/', '', $asset->getTargetPath());
     if (!is_dir($dir = dirname($target))) {
         $output->writeln('<info>[dir+]</info> ' . $dir);
         if (false === @mkdir($dir, 0777, true)) {
             throw new \RuntimeException('Unable to create directory ' . $dir);
         }
     }
     $output->writeln('<info>[file+]</info> ' . $target);
     if (false === @file_put_contents($target, $asset->dump())) {
         throw new \RuntimeException('Unable to write file ' . $target);
     }
 }
開發者ID:rfc1483,項目名稱:doctrine,代碼行數:22,代碼來源:DumpCommand.php

示例14: dumpAsset

    /**
     * Writes an asset.
     *
     * @param AssetInterface  $asset   An asset
     * @param string          $basePath The base directory to write to
     * @param OutputInterface $output  The command output
     *
     * @throws RuntimeException If there is a problem writing the asset
     */
    protected function dumpAsset(AssetInterface $asset, $basePath, OutputInterface $output)
    {
        $target = rtrim($basePath, '/') . '/' . $asset->getTargetUrl();
        if (!is_dir($dir = dirname($target))) {
            $output->writeln('<info>[dir+]</info> '.$dir);
            if (false === @mkdir($dir, 0777, true)) {
                throw new \RuntimeException('Unable to create directory '.$dir);
            }
        }

        $output->writeln('<info>[file+]</info> '.$target);
        if (false === @file_put_contents($target, $asset->dump())) {
            throw new \RuntimeException('Unable to write file '.$target);
        }
    }
開發者ID:nacef,項目名稱:symfony,代碼行數:24,代碼來源:DumpCommand.php

示例15: dump

 /**
  * {@inheritdoc}
  */
 public function dump(FilterInterface $additionalFilter = null)
 {
     return $this->asset->dump($additionalFilter);
 }
開發者ID:bit3,項目名稱:contao-theme-plus,代碼行數:7,代碼來源:AbstractDelegatorAsset.php


注:本文中的Assetic\Asset\AssetInterface::dump方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。