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


PHP Asset\AssetInterface類代碼示例

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


在下文中一共展示了AssetInterface類的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: filterDump

 public function filterDump(AssetInterface $asset)
 {
     $content = $asset->getContent();
     //Do something to $content
     $img_src = "http://www.sopinet.com/layout/bootstrap/template/sopinetoliva_mini.png";
     $asset->setContent(ColorizeService::autoColorizeFromString($content, $img_src));
 }
開發者ID:sopinet,項目名稱:colorizebundle,代碼行數:7,代碼來源:ColorizeFilter.php

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

示例4: filterLoad

 public function filterLoad(AssetInterface $asset)
 {
     $builder = $this->createProcessBuilder($this->nodeBin ? array($this->nodeBin, $this->jsxBin) : array($this->jsxBin));
     $inputDir = FilesystemUtils::createThrowAwayDirectory('jsx_in');
     $inputFile = $inputDir . DIRECTORY_SEPARATOR . 'asset.js';
     $outputDir = FilesystemUtils::createThrowAwayDirectory('jsx_out');
     $outputFile = $outputDir . DIRECTORY_SEPARATOR . 'asset.js';
     // create the asset file
     file_put_contents($inputFile, $asset->getContent());
     $builder->add($inputDir)->add($outputDir)->add('--no-cache-dir');
     $proc = $builder->getProcess();
     $code = $proc->run();
     // remove the input directory and asset file
     unlink($inputFile);
     rmdir($inputDir);
     if (0 !== $code) {
         if (file_exists($outputFile)) {
             unlink($outputFile);
         }
         if (file_exists($outputDir)) {
             rmdir($outputDir);
         }
         throw FilterException::fromProcess($proc);
     }
     $asset->setContent(file_get_contents($outputFile));
     // remove the output directory and processed asset file
     unlink($outputFile);
     rmdir($outputDir);
 }
開發者ID:mohamedsharaf,項目名稱:assetic,代碼行數:29,代碼來源:ReactJsxFilter.php

示例5: filterLoad

 public function filterLoad(AssetInterface $asset)
 {
     $pb = $this->createProcessBuilder($this->nodeBin ? array($this->nodeBin, $this->emberBin) : array($this->emberBin));
     $templateName = basename($asset->getSourcePath());
     $inputDirPath = sys_get_temp_dir() . DIRECTORY_SEPARATOR . uniqid('input_dir');
     $inputPath = $inputDirPath . DIRECTORY_SEPARATOR . $templateName;
     $outputPath = tempnam(sys_get_temp_dir(), 'output');
     mkdir($inputDirPath);
     file_put_contents($inputPath, $asset->getContent());
     $pb->add($inputPath)->add('-f')->add($outputPath);
     if ($this->includeBaseDir) {
         $pb->add('-b')->add($inputDirPath . DIRECTORY_SEPARATOR);
     }
     $process = $pb->getProcess();
     $returnCode = $process->run();
     unlink($inputPath);
     rmdir($inputDirPath);
     if (127 === $returnCode) {
         throw new \RuntimeException('Path to node executable could not be resolved.');
     }
     if (0 !== $returnCode) {
         if (file_exists($outputPath)) {
             unlink($outputPath);
         }
         throw FilterException::fromProcess($process)->setInput($asset->getContent());
     }
     if (!file_exists($outputPath)) {
         throw new \RuntimeException('Error creating output file.');
     }
     $compiledJs = file_get_contents($outputPath);
     unlink($outputPath);
     $asset->setContent($compiledJs);
 }
開發者ID:gsomoza,項目名稱:TimeTracking,代碼行數:33,代碼來源:EmberPrecompileFilter.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: filterDump

 public function filterDump(AssetInterface $asset)
 {
     $content = $asset->getContent();
     $config = array_merge(array('filename' => $asset->getSourcePath()), $this->config);
     $content = Compiler::compile($content, $config);
     $asset->setContent($content);
 }
開發者ID:codesleeve,項目名稱:asset-pipeline,代碼行數:7,代碼來源:CoffeeScript.php

示例8: filterDump

 public function filterDump(AssetInterface $asset)
 {
     $pb = new ProcessBuilder();
     $pb->inheritEnvironmentVariables()->add($this->jpegtranBin);
     if ($this->optimize) {
         $pb->add('-optimize');
     }
     if ($this->copy) {
         $pb->add('-copy')->add($this->copy);
     }
     if ($this->progressive) {
         $pb->add('-progressive');
     }
     if (null !== $this->restart) {
         $pb->add('-restart')->add($this->restart);
     }
     $pb->add($input = tempnam(sys_get_temp_dir(), 'assetic_jpegtran'));
     file_put_contents($input, $asset->getContent());
     $proc = $pb->getProcess();
     $code = $proc->run();
     unlink($input);
     if (0 < $code) {
         throw new \RuntimeException($proc->getErrorOutput());
     }
     $asset->setContent($proc->getOutput());
 }
開發者ID:laiello,項目名稱:mediathequescrum,代碼行數:26,代碼來源:JpegtranFilter.php

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

示例10: filterLoad

 public function filterLoad(AssetInterface $asset)
 {
     $pb = $this->createProcessBuilder($this->nodeBin ? array($this->nodeBin, $this->emberBin) : array($this->emberBin));
     if ($sourcePath = $asset->getSourcePath()) {
         $templateName = basename($sourcePath);
     } else {
         throw new \LogicException('The embed-precompile filter requires that assets have a source path set');
     }
     $inputDirPath = FilesystemUtils::createThrowAwayDirectory('ember_in');
     $inputPath = $inputDirPath . DIRECTORY_SEPARATOR . $templateName;
     $outputPath = FilesystemUtils::createTemporaryFile('ember_out');
     file_put_contents($inputPath, $asset->getContent());
     $pb->add($inputPath)->add('-f')->add($outputPath);
     $process = $pb->getProcess();
     $returnCode = $process->run();
     unlink($inputPath);
     rmdir($inputDirPath);
     if (127 === $returnCode) {
         throw new \RuntimeException('Path to node executable could not be resolved.');
     }
     if (0 !== $returnCode) {
         if (file_exists($outputPath)) {
             unlink($outputPath);
         }
         throw FilterException::fromProcess($process)->setInput($asset->getContent());
     }
     if (!file_exists($outputPath)) {
         throw new \RuntimeException('Error creating output file.');
     }
     $compiledJs = file_get_contents($outputPath);
     unlink($outputPath);
     $asset->setContent($compiledJs);
 }
開發者ID:BusinessCookies,項目名稱:CoffeeMachineProject,代碼行數:33,代碼來源:EmberPrecompileFilter.php

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

示例12: process

 public function process(AssetInterface $asset)
 {
     if (0 < preg_match($this->pattern, $asset->getTargetUrl())) {
         $asset->ensureFilter($this->filter);
     }
     return $asset;
 }
開發者ID:norwayapp,項目名稱:Invest,代碼行數:7,代碼來源:EnsureFilterWorker.php

示例13: filterDump

 public function filterDump(AssetInterface $asset)
 {
     $script = $asset->getContent();
     $packer = new \JavaScriptPacker($script, $this->_encoding, $this->_fastDecode, $this->_specialChars);
     $script = $packer->pack();
     $asset->setContent(str_replace(";;", ";", trim($script) . ";"));
 }
開發者ID:icedream,項目名稱:javascriptpackerbundle,代碼行數:7,代碼來源:JavaScriptPackerFilter.php

示例14: filterDump

 public function filterDump(AssetInterface $asset)
 {
     $options = array($this->jpegtranBin);
     if ($this->optimize) {
         $options[] = '-optimize';
     }
     if ($this->copy) {
         $options[] = '-copy';
         $options[] = $this->copy;
     }
     if ($this->progressive) {
         $options[] = '-progressive';
     }
     if (null !== $this->restart) {
         $options[] = '-restart';
         $options[] = $this->restart;
     }
     $options[] = $input = tempnam(sys_get_temp_dir(), 'assetic_jpegtran');
     file_put_contents($input, $asset->getContent());
     $proc = new Process(implode(' ', array_map('escapeshellarg', $options)));
     $code = $proc->run();
     unlink($input);
     if (0 < $code) {
         throw new \RuntimeException($proc->getErrorOutput());
     }
     $asset->setContent($proc->getOutput());
 }
開發者ID:norwayapp,項目名稱:Invest,代碼行數:27,代碼來源:JpegtranFilter.php

示例15: filterLoad

 public function filterLoad(AssetInterface $asset)
 {
     $pb = $this->createProcessBuilder($this->nodeBin ? array($this->nodeBin, $this->tscBin) : array($this->tscBin));
     if ($sourcePath = $asset->getSourcePath()) {
         $templateName = basename($sourcePath);
     } else {
         $templateName = 'asset';
     }
     $inputDirPath = FilesystemUtils::createThrowAwayDirectory('typescript_in');
     $inputPath = $inputDirPath . DIRECTORY_SEPARATOR . $templateName . '.ts';
     $outputPath = FilesystemUtils::createTemporaryFile('typescript_out');
     file_put_contents($inputPath, $asset->getContent());
     $pb->add($inputPath)->add('--out')->add($outputPath);
     $proc = $pb->getProcess();
     $code = $proc->run();
     unlink($inputPath);
     rmdir($inputDirPath);
     if (0 !== $code) {
         if (file_exists($outputPath)) {
             unlink($outputPath);
         }
         throw FilterException::fromProcess($proc)->setInput($asset->getContent());
     }
     if (!file_exists($outputPath)) {
         throw new \RuntimeException('Error creating output file.');
     }
     $compiledJs = file_get_contents($outputPath);
     unlink($outputPath);
     $asset->setContent($compiledJs);
 }
開發者ID:BusinessCookies,項目名稱:CoffeeMachineProject,代碼行數:30,代碼來源:TypeScriptFilter.php


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