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


PHP AssetInterface::getContent方法代码示例

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


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

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

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

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

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

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

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

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

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

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

示例11: filterLoad

 public function filterLoad(AssetInterface $asset)
 {
     $content = $asset->getContent();
     $root = $asset->getSourceRoot();
     $path = $asset->getSourcePath();
     if (!empty($content)) {
         $content = \CoffeeScript\Compiler::compile($asset->getContent(), array('filename' => $path));
     }
     $asset->setContent($content);
 }
开发者ID:nicolas-brousse,项目名称:twig-integrator-kit,代码行数:10,代码来源:CoffeephpFilter.php

示例12: filterDump

 public function filterDump(AssetInterface $asset)
 {
     switch ($this->type) {
         case 'css':
             $cssMin = new CSSMin();
             $content = $cssMin->run($asset->getContent());
             break;
         case 'js':
             $content = JSMin::minify($asset->getContent());
             break;
     }
     $asset->setContent($content);
 }
开发者ID:toopay,项目名称:assetic-minifier,代码行数:13,代码来源:MinFilter.php

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

示例14: filterDump

 public function filterDump(AssetInterface $asset)
 {
     $is64bit = PHP_INT_SIZE === 8;
     $cleanup = array();
     $pb = new ProcessBuilder(array_merge(array($this->javaPath), $is64bit ? array('-server', '-XX:+TieredCompilation') : array('-client', '-d32'), array('-jar', $this->jarPath)));
     if (null !== $this->timeout) {
         $pb->setTimeout($this->timeout);
     }
     if (null !== $this->compilationLevel) {
         $pb->add('--compilation_level')->add($this->compilationLevel);
     }
     if (null !== $this->jsExterns) {
         $cleanup[] = $externs = tempnam(sys_get_temp_dir(), 'assetic_google_closure_compiler');
         file_put_contents($externs, $this->jsExterns);
         $pb->add('--externs')->add($externs);
     }
     if (null !== $this->externsUrl) {
         $cleanup[] = $externs = tempnam(sys_get_temp_dir(), 'assetic_google_closure_compiler');
         file_put_contents($externs, file_get_contents($this->externsUrl));
         $pb->add('--externs')->add($externs);
     }
     if (null !== $this->excludeDefaultExterns) {
         $pb->add('--use_only_custom_externs');
     }
     if (null !== $this->formatting) {
         $pb->add('--formatting')->add($this->formatting);
     }
     if (null !== $this->useClosureLibrary) {
         $pb->add('--manage_closure_dependencies');
     }
     if (null !== $this->warningLevel) {
         $pb->add('--warning_level')->add($this->warningLevel);
     }
     if (null !== $this->language) {
         $pb->add('--language_in')->add($this->language);
     }
     if (null !== $this->flagFile) {
         $pb->add('--flagfile')->add($this->flagFile);
     }
     $pb->add('--js')->add($cleanup[] = $input = tempnam(sys_get_temp_dir(), 'assetic_google_closure_compiler'));
     file_put_contents($input, $asset->getContent());
     $proc = $pb->getProcess();
     $code = $proc->run();
     array_map('unlink', $cleanup);
     if (0 !== $code) {
         throw FilterException::fromProcess($proc)->setInput($asset->getContent());
     }
     $asset->setContent($proc->getOutput());
 }
开发者ID:neteasy-work,项目名称:hkgbf_crm,代码行数:49,代码来源:CompilerJarFilter.php

示例15: filterLoad

 public function filterLoad(AssetInterface $asset)
 {
     $input = tempnam(sys_get_temp_dir(), 'assetic_roole');
     file_put_contents($input, $asset->getContent());
     $pb = $this->createProcessBuilder($this->nodeBin ? array($this->nodeBin, $this->rooleBin) : array($this->rooleBin));
     $pb->add('-p');
     $pb->add($input);
     $proc = $pb->getProcess();
     $code = $proc->run();
     unlink($input);
     if (0 !== $code) {
         throw FilterException::fromProcess($proc)->setInput($asset->getContent());
     }
     $asset->setContent($proc->getOutput());
 }
开发者ID:alexBLR,项目名称:firmware,代码行数:15,代码来源:RooleFilter.php


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