本文整理汇总了PHP中Assetic\Exception\FilterException类的典型用法代码示例。如果您正苦于以下问题:PHP FilterException类的具体用法?PHP FilterException怎么用?PHP FilterException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FilterException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: 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
示例17: 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
示例18: filterLoad
public function filterLoad(AssetInterface $asset)
{
$input = tempnam(sys_get_temp_dir(), 'assetic_coffeescript');
file_put_contents($input, $asset->getContent());
$pb = new ProcessBuilder(array($this->nodePath, $this->coffeePath, '-cp'));
if ($this->bare) {
$pb->add('--bare');
}
$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:laubosslink,项目名称:lab,代码行数:17,代码来源:CoffeeScriptFilter.php
示例19: filterLoad
public function filterLoad(AssetInterface $asset)
{
$input = $asset->getContent();
$pb = $this->createProcessBuilder(array($this->autoprefixerBin));
$pb->setInput($input);
if ($this->browsers) {
$pb->add('-b')->add(implode(',', $this->browsers));
}
$output = tempnam(sys_get_temp_dir(), 'assetic_autoprefixer');
$pb->add('-o')->add($output);
$proc = $pb->getProcess();
if (0 !== $proc->run()) {
throw FilterException::fromProcess($proc)->setInput($asset->getContent());
}
$asset->setContent(file_get_contents($output));
unlink($output);
}
开发者ID:lk1ngaa7,项目名称:assetic,代码行数:17,代码来源:AutoprefixerFilter.php
示例20: filterLoad
public function filterLoad(AssetInterface $asset)
{
$input = FilesystemUtils::createTemporaryFile('dart');
$output = FilesystemUtils::createTemporaryFile('dart');
file_put_contents($input, $asset->getContent());
$pb = $this->createProcessBuilder()->add($this->dartBin)->add('-o' . $output)->add($input);
$proc = $pb->getProcess();
$code = $proc->run();
unlink($input);
if (0 !== $code) {
$this->cleanup($output);
throw FilterException::fromProcess($proc);
}
if (!file_exists($output)) {
throw new \RuntimeException('Error creating output file.');
}
$asset->setContent(file_get_contents($output));
$this->cleanup($output);
}
开发者ID:BusinessCookies,项目名称:CoffeeMachineProject,代码行数:19,代码来源:DartFilter.php
注:本文中的Assetic\Exception\FilterException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论