filesystem = $filesystem; $this->recess = $recess; } public static function create(Application $app) { $binaries = $app['phraseanet.configuration']['binaries']; return new self($app['filesystem'], RecessDriver::create($binaries)); } /** * Compile LESS files * * @param string $target * @param string $files * * @throws RuntimeException */ public function compile($target, $files) { $this->filesystem->mkdir(dirname($target)); if (!$files instanceof \Traversable) { $files = new \ArrayObject(is_array($files) ? $files : array($files)); } $files = (array) $files; foreach ($files as $file) { if (false === is_file($file)) { throw new RuntimeException($file . ' does not exists.'); } } if (!is_writable(dirname($target))) { throw new RuntimeException(realpath(dirname($target)) . ' is not writable.'); } $commands = $files; array_unshift($commands, '--compile'); try { $output = $this->recess->command($commands); $this->filesystem->dumpFile($target, $output); } catch (ExecutionFailureException $e) { throw new RuntimeException('Could not execute recess command.', $e->getCode(), $e); } } }