mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-10 19:43:16 +00:00
Make builder service stateless
This commit is contained in:
@@ -12,7 +12,6 @@
|
||||
namespace Alchemy\Phrasea\Command\Developer;
|
||||
|
||||
use Alchemy\Phrasea\Command\Command;
|
||||
use Alchemy\Phrasea\Utilities\Compiler\RecessLessCompiler;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
@@ -21,16 +20,11 @@ use Symfony\Component\Console\Output\OutputInterface;
|
||||
*/
|
||||
class LessCompiler extends Command
|
||||
{
|
||||
private $recessLessCompiler;
|
||||
|
||||
public function __construct($recessLessCompiler = null)
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('assets:compile-less');
|
||||
|
||||
$this->setDescription('Compile less files');
|
||||
|
||||
|
||||
$this->recessLessCompiler = $recessLessCompiler ?: new RecessLessCompiler();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -57,8 +51,10 @@ class LessCompiler extends Command
|
||||
|
||||
$output->writeln('Building Assets...');
|
||||
|
||||
if (false === $this->container['phraseanet.less-builder']->build($files)) {
|
||||
$output->writeln(sprintf('<error>Errors occured during the build %s</error>', implode(', ', $this->container['phraseanet.less-builder']->getErrors())));
|
||||
$errors = $this->container['phraseanet.less-builder']->build($files);
|
||||
|
||||
if (count($errors) > 0) {
|
||||
$output->writeln(sprintf('<error>Errors occured during the build %s</error>', implode(', ', $errors)));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@@ -38,12 +38,16 @@ abstract class AbstractPluginCommand extends Command
|
||||
$this->container['plugins.autoloader-generator']->write($manifests);
|
||||
$output->writeln(" <comment>OK</comment>");
|
||||
|
||||
$output->write('Building Assets...');
|
||||
if (false === $this->container['phraseanet.less-builder']->build(array(
|
||||
$files = array(
|
||||
$this->container['root.path'] . '/www/skins/login/less/login.less' => $this->container['root.path'] . '/www/skins/build/login.css',
|
||||
$this->container['root.path'] . '/www/skins/account/account.less' => $this->container['root.path'] . '/www/skins/build/account.css',
|
||||
))) {
|
||||
$output->writeln(sprintf('<error>Error(s) occured during the build %s</error>', implode(', ', $this->container['phraseanet.less-builder']->getErrors())));
|
||||
);
|
||||
|
||||
$output->write('Building Assets...');
|
||||
$errors = $this->container['phraseanet.less-builder']->build($files);
|
||||
|
||||
if (count($errors) > 0) {
|
||||
$output->writeln(sprintf('<error>Error(s) occured during the build %s</error>', implode(', ', $errors)));
|
||||
}
|
||||
$output->writeln(" <comment>OK</comment>");
|
||||
}
|
||||
|
@@ -24,10 +24,6 @@ class Builder
|
||||
* @var Filesystem
|
||||
*/
|
||||
protected $filesystem;
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $errors = array();
|
||||
|
||||
public function __construct(LessCompiler $compiler, Filesystem $filesystem)
|
||||
{
|
||||
@@ -43,7 +39,7 @@ class Builder
|
||||
public function build($files)
|
||||
{
|
||||
$failures = 0;
|
||||
$this->errors = array();
|
||||
$errors = array();
|
||||
|
||||
foreach ($files as $lessFile => $target) {
|
||||
$this->filesystem->mkdir(dirname($target));
|
||||
@@ -52,20 +48,10 @@ class Builder
|
||||
$this->compiler->compile($target, $lessFile);
|
||||
} catch (\Exception $e) {
|
||||
$failures++;
|
||||
$this->errors[] = $e->getMessage();
|
||||
$errors[] = $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
return $this->hasErrors();
|
||||
}
|
||||
|
||||
public function hasErrors()
|
||||
{
|
||||
return count($this->errors) === 0;
|
||||
}
|
||||
|
||||
public function getErrors()
|
||||
{
|
||||
return $this->errors;
|
||||
return $errors;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user