Source of file DartFilter.php
Size: 1,576 Bytes - Last Modified: 2013-06-02T00:13:43+02:00
/home/theseer/Downloads/Symfony/vendor/kriswallsmith/assetic/src/Assetic/Filter/DartFilter.php
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 | <?php /* * This file is part of the Assetic package, an OpenSky project. * * (c) 2010-2013 OpenSky Project Inc * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Assetic\Filter; use Assetic\Asset\AssetInterface; use Assetic\Exception\FilterException; /** * Compiles Dart into Javascript. * * @link http://dartlang.org/ */ class DartFilter extends BaseProcessFilter { private $dartBin; public function __construct($dartBin = '/usr/bin/dart2js') { $this->dartBin = $dartBin; } public function filterLoad(AssetInterface $asset) { $input = tempnam(sys_get_temp_dir(), 'assetic_dart'); $output = tempnam(sys_get_temp_dir(), 'assetic_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) { 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); } public function filterDump(AssetInterface $asset) { } } |