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


PHP AssetInterface::setContent方法代码示例

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


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

 /**
  * 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

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

示例4: filterDump

 public function filterDump(AssetInterface $asset)
 {
     $defaultLoader = $this->twig->getLoader();
     $this->twig->setLoader($this->loader);
     $asset->setContent($this->twig->render($asset->getContent()));
     $this->twig->setLoader($defaultLoader);
 }
开发者ID:electrotiti,项目名称:twig-assetic-filter-bundle,代码行数:7,代码来源:TwigFilter.php

示例5: filterDump

    /**
     * {@inheritdoc}
     */
    public function filterDump(AssetInterface $asset)
    {
        if (preg_match('/pace_settings\\.js$/', $asset->getSourcePath())) {
            $ajax = $this->config['pace']['ajax'] ? 'true' : 'false';
            $document = $this->config['pace']['document'] ? 'true' : 'false';
            $eventLag = $this->config['pace']['eventLag'] ? 'true' : 'false';
            $restartOnPushState = $this->config['pace']['restartOnPushState'] ? 'true' : 'false';
            $restartOnRequestAfter = $this->config['pace']['restartOnRequestAfter'] ? 'true' : 'false';
            $settings = <<<JAVASCRIPT
var paceOptions = {
  ajax: {$ajax}, 
  document: {$document}, 
  eventLag: {$eventLag},
  restartOnPushState: {$restartOnPushState},
  restartOnRequestAfter: {$restartOnRequestAfter},
};
if (typeof requirejs !== 'undefined'){
    require(['pace'], function (pace) {
      pace.start();
    });
}

JAVASCRIPT;
            $asset->setContent($settings);
        }
    }
开发者ID:ynloultratech,项目名称:framework,代码行数:29,代码来源:PaceSettingsDumper.php

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

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

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

示例9: filterLoad

    public function filterLoad(AssetInterface $asset)
    {
        $sourceUrl = $asset->getSourceUrl();
        if (!$sourceUrl || false !== strpos($sourceUrl, '://')) {
            return;
        }

        $options = array($this->sprocketizePath);

        foreach ($this->includeDirs as $directory) {
            $options[] = '-I';
            $options[] = $directory;
        }

        if (null !== $this->assetRoot) {
            $options[] = '-a';
            $options[] = $this->assetRoot;
        }

        // hack in a temporary file sibling
        $options[] = $input = dirname($this->baseDir.'/'.$sourceUrl).'/.'.rand(11111, 99999).'-'.basename($sourceUrl);
        $tmp = tempnam(sys_get_temp_dir(), 'assetic_sprockets');
        file_put_contents($tmp, $asset->getContent());
        rename($tmp, $input);

        $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:nresni,项目名称:symfony-sandbox,代码行数:35,代码来源:SprocketsFilter.php

示例10: filterDump

 /**
  * @param AssetInterface $asset
  */
 public function filterDump(AssetInterface $asset)
 {
     $sourceBase = $asset->getSourceRoot();
     $sourcePath = $asset->getSourcePath();
     $assetRoot = $this->assetRoot;
     if (null === $sourcePath) {
         return;
     }
     $content = $this->filterReferences($asset->getContent(), function ($matches) use($sourceBase, $sourcePath, $assetRoot) {
         // its not a relative path
         if (false !== strpos($matches['url'], '://') || 0 === strpos($matches['url'], '//') || 0 === strpos($matches['url'], 'data:') || isset($matches['url'][0]) && '/' == $matches['url'][0]) {
             return $matches[0];
         }
         $url = $matches['url'];
         if (false !== ($pos = strpos($url, '?'))) {
             $url = substr($url, 0, $pos);
         }
         $sourceAsset = dirname($sourceBase . '/' . $sourcePath) . '/' . $url;
         if (!is_file($sourceAsset)) {
             return $matches[0];
         }
         $mimeType = MimeTypeGuesser::getInstance()->guess($sourceAsset);
         $destRelativePath = substr($mimeType, 0, strpos($mimeType, '/')) . '/' . basename($url);
         $destAsset = $assetRoot . '/' . $destRelativePath;
         if (!is_dir(dirname($destAsset))) {
             mkdir(dirname($destAsset), 0777, true);
         }
         copy($sourceAsset, $destAsset);
         return str_replace($matches['url'], '../' . $destRelativePath, $matches[0]);
     });
     $asset->setContent($content);
 }
开发者ID:saxulum,项目名称:saxulum-assetic-twig-provider,代码行数:35,代码来源:CssCopyFileFilter.php

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

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

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

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

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


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