diff --git a/lib/Alchemy/Phrasea/Command/Developer/LessCompiler.php b/lib/Alchemy/Phrasea/Command/Developer/LessCompiler.php index 4262a6fa7d..3fa29f0c94 100644 --- a/lib/Alchemy/Phrasea/Command/Developer/LessCompiler.php +++ b/lib/Alchemy/Phrasea/Command/Developer/LessCompiler.php @@ -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('Errors occured during the build %s', implode(', ', $this->container['phraseanet.less-builder']->getErrors()))); + $errors = $this->container['phraseanet.less-builder']->build($files); + + if (count($errors) > 0) { + $output->writeln(sprintf('Errors occured during the build %s', implode(', ', $errors))); return 1; } diff --git a/lib/Alchemy/Phrasea/Command/Plugin/AbstractPluginCommand.php b/lib/Alchemy/Phrasea/Command/Plugin/AbstractPluginCommand.php index 31d2437faf..f3bec54a1f 100644 --- a/lib/Alchemy/Phrasea/Command/Plugin/AbstractPluginCommand.php +++ b/lib/Alchemy/Phrasea/Command/Plugin/AbstractPluginCommand.php @@ -38,12 +38,16 @@ abstract class AbstractPluginCommand extends Command $this->container['plugins.autoloader-generator']->write($manifests); $output->writeln(" OK"); - $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(s) occured during the build %s', 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(s) occured during the build %s', implode(', ', $errors))); } $output->writeln(" OK"); } diff --git a/lib/Alchemy/Phrasea/Utilities/Less/Builder.php b/lib/Alchemy/Phrasea/Utilities/Less/Builder.php index 5789aefcf8..607f1c950a 100644 --- a/lib/Alchemy/Phrasea/Utilities/Less/Builder.php +++ b/lib/Alchemy/Phrasea/Utilities/Less/Builder.php @@ -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; } }