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


PHP Exception\FilterException類代碼示例

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


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

示例1: compress

 protected function compress(AssetInterface $asset, $type, $options = array())
 {
     $pb = $this->createProcessBuilder(array($this->javaPath));
     $pb->add('-jar')->add($this->jarPath);
     foreach ($options as $option) {
         $pb->add($option);
     }
     $this->charset and $pb->add('--charset')->add($this->charset);
     $this->preserveComments and $pb->add('--preserve-comments');
     $this->removeIntertagSpaces and $pb->add('--remove-intertag-spaces');
     // input and output files
     $tempDir = realpath(sys_get_temp_dir());
     $input = tempnam($tempDir, 'assetic_htmlcompressor');
     $output = tempnam($tempDir, 'assetic_htmlcompressor');
     file_put_contents($input, $asset->getContent());
     $pb->add('-o')->add($output)->add($input);
     $proc = $pb->getProcess();
     $code = $proc->run();
     unlink($input);
     if (0 !== $code || false !== strpos($proc->getOutput(), 'ERROR')) {
         if (file_exists($output)) {
             unlink($output);
         }
         throw FilterException::fromProcess($proc)->setInput($asset->getContent());
     }
     $asset->setContent(file_get_contents($output));
     unlink($output);
 }
開發者ID:francisbesset,項目名稱:carew-assetic,代碼行數:28,代碼來源:AbstractCompressorFilter.php

示例2: compress

 /**
  * Compresses a string.
  *
  * @param string $content The content to compress
  * @param string $type    The type of content, either "js" or "css"
  * @param array  $options An indexed array of additional options
  *
  * @return string The compressed content
  */
 protected function compress($content, $type, $options = array())
 {
     $pb = new ProcessBuilder(array($this->javaPath, '-jar', $this->jarPath));
     foreach ($options as $option) {
         $pb->add($option);
     }
     if (null !== $this->charset) {
         $pb->add('--charset')->add($this->charset);
     }
     if (null !== $this->lineBreak) {
         $pb->add('--line-break')->add($this->lineBreak);
     }
     // input and output files
     $tempDir = realpath(sys_get_temp_dir());
     $hash = substr(sha1(time() . rand(11111, 99999)), 0, 7);
     $input = $tempDir . DIRECTORY_SEPARATOR . $hash . '.' . $type;
     $output = $tempDir . DIRECTORY_SEPARATOR . $hash . '-min.' . $type;
     file_put_contents($input, $content);
     $pb->add('-o')->add($output)->add($input);
     $proc = $pb->getProcess();
     $code = $proc->run();
     unlink($input);
     if (0 < $code) {
         if (file_exists($output)) {
             unlink($output);
         }
         throw FilterException::fromProcess($proc)->setInput($content);
     } elseif (!file_exists($output)) {
         throw new \RuntimeException('Error creating output file.');
     }
     $retval = file_get_contents($output);
     unlink($output);
     return $retval;
 }
開發者ID:noisebleed,項目名稱:markdown-resume,代碼行數:43,代碼來源:BaseCompressorFilter.php

示例3: filterLoad

 public function filterLoad(AssetInterface $asset)
 {
     $sassProcessArgs = array($this->binaryPath);
     $pb = $this->createProcessBuilder($sassProcessArgs);
     $pb->add('--stdout');
     $assetDirectory = '';
     if (method_exists($asset, 'getSourceDirectory')) {
         $assetDirectory = $asset->getSourceDirectory();
     } else {
         $root = $asset->getSourceRoot();
         $path = $asset->getSourcePath();
         $assetDirectory = dirname($root . '/' . $path);
     }
     $allLoadPaths = $this->loadPaths;
     array_unshift($allLoadPaths, $assetDirectory);
     $pb->add('--include-path')->add(implode(':', $allLoadPaths));
     if ($this->style) {
         $pb->add('--output-style')->add($this->style);
     }
     if ($this->sourceComments) {
         $pb->add('--source-comments')->add($this->sourceComments);
     }
     if ($this->emitSourceMap) {
         $pb->add('--source-map');
     }
     $pb->add($asset->getSourceRoot() . '/' . $asset->getSourcePath());
     $pb->add(storage_path() . '/cache/sassc');
     $process = $pb->getProcess();
     $code = $process->run();
     if (0 !== $code) {
         throw FilterException::fromProcess($process);
     }
     $asset->setContent($process->getOutput());
 }
開發者ID:asentner,項目名稱:assetic-filters,代碼行數:34,代碼來源:SasscFilter.php

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

示例5: filterDump

 public function filterDump(AssetInterface $asset)
 {
     $pb = $this->createProcessBuilder($this->nodeBin ? array($this->nodeBin, $this->uglifyjsBin) : array($this->uglifyjsBin));
     if ($this->compress) {
         $pb->add('--compress');
     }
     if ($this->beautify) {
         $pb->add('--beautify');
     }
     if ($this->mangle) {
         $pb->add('--mangle');
     }
     // input and output files
     $input = tempnam(sys_get_temp_dir(), 'input');
     $output = tempnam(sys_get_temp_dir(), 'output');
     file_put_contents($input, $asset->getContent());
     $pb->add('-o')->add($output)->add($input);
     $proc = $pb->getProcess();
     $code = $proc->run();
     unlink($input);
     if (0 < $code) {
         if (file_exists($output)) {
             unlink($output);
         }
         if (127 === $code) {
             throw new \RuntimeException('Path to node executable could not be resolved.');
         }
         throw FilterException::fromProcess($proc)->setInput($asset->getContent());
     }
     if (!file_exists($output)) {
         throw new \RuntimeException('Error creating output file.');
     }
     $asset->setContent(file_get_contents($output));
     unlink($output);
 }
開發者ID:bmavus,項目名稱:wp-theme-blank,代碼行數:35,代碼來源:UglifyJs2Filter.php

示例6: filterDump

 public function filterDump(AssetInterface $asset)
 {
     $pb = $this->createProcessBuilder(array($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 FilterException::fromProcess($proc)->setInput($asset->getContent());
     }
     $asset->setContent($proc->getOutput());
 }
開發者ID:Wilsoncreative,項目名稱:bloggkit,代碼行數:25,代碼來源:JpegtranFilter.php

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

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

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

示例10: compress

 /**
  * Compresses a string.
  *
  * @param string $content The content to compress
  * @param string $type    The type of content, either "js" or "css"
  * @param array  $options An indexed array of additional options
  *
  * @return string The compressed content
  */
 protected function compress($content, $type, $options = array())
 {
     $pb = $this->createProcessBuilder(array($this->javaPath, '-jar', $this->jarPath));
     foreach ($options as $option) {
         $pb->add($option);
     }
     if (null !== $this->charset) {
         $pb->add('--charset')->add($this->charset);
     }
     if (null !== $this->lineBreak) {
         $pb->add('--line-break')->add($this->lineBreak);
     }
     // input and output files
     $tempDir = realpath(sys_get_temp_dir());
     $input = tempnam($tempDir, 'YUI-IN-');
     $output = tempnam($tempDir, 'YUI-OUT-');
     file_put_contents($input, $content);
     $pb->add('-o')->add($output)->add('--type')->add($type)->add($input);
     $proc = $pb->getProcess();
     $code = $proc->run();
     unlink($input);
     if (0 < $code) {
         if (file_exists($output)) {
             unlink($output);
         }
         throw FilterException::fromProcess($proc)->setInput($content);
     }
     if (!file_exists($output)) {
         throw new \RuntimeException('Error creating output file.');
     }
     $retval = file_get_contents($output);
     unlink($output);
     return $retval;
 }
開發者ID:kurozumi,項目名稱:UserManagement,代碼行數:43,代碼來源:BaseCompressorFilter.php

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

示例12: filterDump

 /**
  * Filters an asset just before it's dumped.
  *
  * @param AssetInterface $asset An asset
  */
 public function filterDump(AssetInterface $asset)
 {
     $pb = $this->createProcessBuilder($this->nodeBin ? array($this->nodeBin, $this->cssoPath) : array($this->cssoPath));
     // input and output files
     $input = tempnam(sys_get_temp_dir(), 'input');
     $output = tempnam(sys_get_temp_dir(), 'output');
     file_put_contents($input, $asset->getContent());
     $pb->add('-i')->add($input);
     $pb->add('-o')->add($output);
     $process = $pb->getProcess();
     $code = $process->run();
     unlink($input);
     if (0 !== $code) {
         if (file_exists($output)) {
             unlink($output);
         }
         if (127 === $code) {
             throw new \RuntimeException('Path to node executable could not be resolved.');
         }
         throw FilterException::fromProcess($process)->setInput($asset->getContent());
     }
     if (!file_exists($output)) {
         throw new \RuntimeException('Error creating output file.');
     }
     $csso = file_get_contents($output);
     unlink($output);
     $asset->setContent($csso);
 }
開發者ID:enlitepro,項目名稱:enlite-assetic,代碼行數:33,代碼來源:CssoFilter.php

示例13: filterDump

 /**
  * Filters an asset just before it's dumped.
  *
  * @param AssetInterface $asset An asset
  */
 public function filterDump(AssetInterface $asset)
 {
     $pb = $this->createProcessBuilder($this->nodeBin ? array($this->nodeBin, $this->htmlMinifierBin) : array($this->htmlMinifierBin));
     // input and output files
     $input = tempnam(sys_get_temp_dir(), 'input');
     $output = tempnam(sys_get_temp_dir(), 'output');
     file_put_contents($input, $asset->getContent());
     foreach ($this->getOptions() as $option) {
         $pb->add('--' . $option);
     }
     $pb->add('--output');
     $pb->add($output);
     $pb->add($input);
     $proc = $pb->getProcess();
     $code = $proc->run();
     unlink($input);
     if (0 !== $code) {
         if (file_exists($output)) {
             unlink($output);
         }
         throw FilterException::fromProcess($proc)->setInput($asset->getContent());
     }
     if (!file_exists($output)) {
         throw new \RuntimeException('Error creating output file.');
     }
     $asset->setContent(file_get_contents($output));
     unlink($output);
 }
開發者ID:enlitepro,項目名稱:enlite-assetic,代碼行數:33,代碼來源:HtmlMinifierFilter.php

示例14: filterLoad

 public function filterLoad(AssetInterface $asset)
 {
     $pb = $this->createProcessBuilder($this->nodeBin ? array($this->nodeBin, $this->tscBin) : array($this->tscBin));
     $templateName = basename($asset->getSourcePath());
     $inputDirPath = sys_get_temp_dir() . DIRECTORY_SEPARATOR . uniqid('input_dir');
     $inputPath = $inputDirPath . DIRECTORY_SEPARATOR . $templateName . '.ts';
     $outputPath = tempnam(sys_get_temp_dir(), 'output');
     mkdir($inputDirPath);
     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:ccq18,項目名稱:EduSoho,代碼行數:27,代碼來源:TypeScriptFilter.php

示例15: filterDump

 public function filterDump(AssetInterface $asset)
 {
     $pb = $this->createProcessBuilder(array($this->ttf2eotBin));
     $input = tempnam(sys_get_temp_dir(), 'assetic_ttf2eot');
     file_put_contents($input, $asset->getContent());
     $pb->add($input);
     $proc = $pb->getProcess();
     $code = $proc->run();
     unlink($input);
     if ($code !== 0) {
         throw FilterException::fromProcess($proc)->setInput($asset->getContent());
     }
     $asset->setContent($proc->getOutput());
 }
開發者ID:renaatdemuynck,項目名稱:assetic-font-filters,代碼行數:14,代碼來源:Ttf2eotFilter.php


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