diff --git a/.travis.yml b/.travis.yml index e1cff0b50b..967efb667b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -54,8 +54,8 @@ php: - 5.5 script: - - bin/setup system:upgrade -y -v -f - bin/developer dependencies:all --prefer-source + - bin/setup system:upgrade -y -v -f - php hudson/cleanupSubdefs.php - bin/developer assets:compile-less - bin/developer assets:build-javascript diff --git a/bin/developer b/bin/developer index f52158113e..07c5c1bde2 100755 --- a/bin/developer +++ b/bin/developer @@ -57,14 +57,16 @@ try { under certain conditions; type `about:license' for details.\n\n" . ' Phraseanet Developer Tools ', Version::getName() . ' ' . Version::getNumber()); - $helpers = array( - 'db' => new ConnectionHelper($cli['EM']->getConnection()), - 'em' => new EntityManagerHelper($cli['EM']) - ); + if ($cli['phraseanet.configuration']->isSetup()) { + $helpers = array( + 'db' => new ConnectionHelper($cli['EM']->getConnection()), + 'em' => new EntityManagerHelper($cli['EM']) + ); - $helperSet = $cli['console']->getHelperSet(); - foreach ($helpers as $name => $helper) { - $helperSet->set($helper, $name); + $helperSet = $cli['console']->getHelperSet(); + foreach ($helpers as $name => $helper) { + $helperSet->set($helper, $name); + } } $cli->command(new InstallAll()); diff --git a/lib/Alchemy/Phrasea/Application.php b/lib/Alchemy/Phrasea/Application.php index 922431cbf0..9949d51475 100644 --- a/lib/Alchemy/Phrasea/Application.php +++ b/lib/Alchemy/Phrasea/Application.php @@ -88,8 +88,6 @@ use Alchemy\Phrasea\Core\Provider\FtpServiceProvider; use Alchemy\Geonames\GeonamesServiceProvider; use Alchemy\Phrasea\Core\Provider\InstallerServiceProvider; use Alchemy\Phrasea\Core\Provider\JMSSerializerServiceProvider; -use Alchemy\Phrasea\Core\Provider\LessBuilderServiceProvider; -use Alchemy\Phrasea\Core\Provider\LessCompilerServiceProvider; use Alchemy\Phrasea\Core\Provider\LocaleServiceProvider; use Alchemy\Phrasea\Core\Provider\NotificationDelivererServiceProvider; use Alchemy\Phrasea\Core\Provider\ORMServiceProvider; @@ -255,8 +253,6 @@ class Application extends SilexApplication $this->register(new PhraseaVersionServiceProvider()); $this->register(new PHPExiftoolServiceProvider()); $this->register(new ReCaptchaServiceProvider()); - $this->register(new LessCompilerServiceProvider()); - $this->register(new LessBuilderServiceProvider()); $this['recaptcha.public-key'] = $this->share(function (Application $app) { if ($app['phraseanet.registry']->get('GV_captchas')) { diff --git a/lib/Alchemy/Phrasea/CLI.php b/lib/Alchemy/Phrasea/CLI.php index 6e68bcf3bc..e779b8d808 100644 --- a/lib/Alchemy/Phrasea/CLI.php +++ b/lib/Alchemy/Phrasea/CLI.php @@ -13,9 +13,10 @@ namespace Alchemy\Phrasea; use Alchemy\Phrasea\Command\CommandInterface; use Symfony\Component\Console; -use Alchemy\Phrasea\Core\CLIProvider\PluginServiceProvider; -use Alchemy\Phrasea\Core\CLIProvider\ComposerSetupServiceProvider; use Alchemy\Phrasea\Core\CLIProvider\CLIDriversServiceProvider; +use Alchemy\Phrasea\Core\CLIProvider\ComposerSetupServiceProvider; +use Alchemy\Phrasea\Core\CLIProvider\LessBuilderServiceProvider; +use Alchemy\Phrasea\Core\CLIProvider\PluginServiceProvider; /** * Phraseanet Command Line Application @@ -52,6 +53,7 @@ class CLI extends Application $this->register(new PluginServiceProvider()); $this->register(new ComposerSetupServiceProvider()); $this->register(new CLIDriversServiceProvider()); + $this->register(new LessBuilderServiceProvider()); $this->bindRoutes(); } diff --git a/lib/Alchemy/Phrasea/Command/Developer/ComposerInstall.php b/lib/Alchemy/Phrasea/Command/Developer/ComposerInstall.php index ff694e45d2..d6ae72c928 100644 --- a/lib/Alchemy/Phrasea/Command/Developer/ComposerInstall.php +++ b/lib/Alchemy/Phrasea/Command/Developer/ComposerInstall.php @@ -54,7 +54,7 @@ class ComposerInstall extends Command $output->writeln("OK"); } } catch (ExecutionFailureException $e) { - throw new RuntimeException('Unable to install bower dependencies', $e->getCode(), $e); + throw new RuntimeException('Unable to install composer dependencies', $e->getCode(), $e); } return 0; diff --git a/lib/Alchemy/Phrasea/Utilities/Less/RecessDriver.php b/lib/Alchemy/Phrasea/Command/Developer/Utils/RecessDriver.php similarity index 77% rename from lib/Alchemy/Phrasea/Utilities/Less/RecessDriver.php rename to lib/Alchemy/Phrasea/Command/Developer/Utils/RecessDriver.php index be447d7948..edf71cecc7 100644 --- a/lib/Alchemy/Phrasea/Utilities/Less/RecessDriver.php +++ b/lib/Alchemy/Phrasea/Command/Developer/Utils/RecessDriver.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Alchemy\Phrasea\Utilities\Less; +namespace Alchemy\Phrasea\Command\Developer\Utils; use Alchemy\BinaryDriver\AbstractBinary; use Psr\Log\LoggerInterface; @@ -18,11 +18,20 @@ use Alchemy\BinaryDriver\ConfigurationInterface; class RecessDriver extends AbstractBinary { + /** + * {@inheritdoc} + */ public function getName() { return 'recess'; } + /** + * @param array|ConfigurationInterface $conf + * @param LoggerInterface $logger + * + * @return RecessDriver + */ public static function create($conf = array(), LoggerInterface $logger = null) { if (!$conf instanceof ConfigurationInterface) { diff --git a/lib/Alchemy/Phrasea/Core/CLIProvider/CLIDriversServiceProvider.php b/lib/Alchemy/Phrasea/Core/CLIProvider/CLIDriversServiceProvider.php index fbe6a4858f..0a494d2785 100644 --- a/lib/Alchemy/Phrasea/Core/CLIProvider/CLIDriversServiceProvider.php +++ b/lib/Alchemy/Phrasea/Core/CLIProvider/CLIDriversServiceProvider.php @@ -14,6 +14,7 @@ namespace Alchemy\Phrasea\Core\CLIProvider; use Alchemy\Phrasea\Command\Developer\Utils\BowerDriver; use Alchemy\Phrasea\Command\Developer\Utils\UglifyJsDriver; use Alchemy\Phrasea\Command\Developer\Utils\ComposerDriver; +use Alchemy\Phrasea\Command\Developer\Utils\RecessDriver; use Silex\Application; use Silex\ServiceProviderInterface; use Symfony\Component\Process\ExecutableFinder; @@ -26,13 +27,21 @@ class CLIDriversServiceProvider implements ServiceProviderInterface return new ExecutableFinder(); }); - $app['driver.bower'] = $app->share(function (Application $app) { - if (isset($app['phraseanet.configuration']['binaries']['bower_binary'])) { - $bowerBinary = $app['phraseanet.configuration']['binaries']['bower_binary']; - } else { - $bowerBinary = $app['executable-finder']->find('bower'); + $app['driver.binary-finder'] = $app->protect(function ($name, $configName) use ($app) { + if (!$app['phraseanet.configuration']->isSetup()) { + return $app['executable-finder']->find($name); } + if (isset($app['phraseanet.configuration']['binaries'][$configName])) { + return $app['phraseanet.configuration']['binaries'][$configName]; + } + + return $app['executable-finder']->find($name); + }); + + $app['driver.bower'] = $app->share(function (Application $app) { + $bowerBinary = $app['driver.binary-finder']('bower', 'bower_binary'); + if (null === $bowerBinary) { throw new RuntimeException('Unable to find bower executable.'); } @@ -40,13 +49,19 @@ class CLIDriversServiceProvider implements ServiceProviderInterface return BowerDriver::create(array('bower.binaries' => $bowerBinary), $app['monolog']); }); - $app['driver.composer'] = $app->share(function (Application $app) { - if (isset($app['phraseanet.configuration']['binaries']['composer_binary'])) { - $composerBinary = $app['phraseanet.configuration']['binaries']['composer_binary']; - } else { - $composerBinary = $app['executable-finder']->find('composer'); + $app['driver.recess'] = $app->share(function (Application $app) { + $recessBinary = $app['driver.binary-finder']('recess', 'recess_binary'); + + if (null === $recessBinary) { + throw new RuntimeException('Unable to find recess executable.'); } + return RecessDriver::create(array('recess.binaries' => $recessBinary), $app['monolog']); + }); + + $app['driver.composer'] = $app->share(function (Application $app) { + $composerBinary = $app['driver.binary-finder']('composer', 'composer_binary'); + if (null === $composerBinary) { throw new RuntimeException('Unable to find composer executable.'); } @@ -55,7 +70,13 @@ class CLIDriversServiceProvider implements ServiceProviderInterface }); $app['driver.uglifyjs'] = $app->share(function (Application $app) { - return UglifyJsDriver::create(array(), $app['monolog']); + $uglifyJsBinary = $app['driver.binary-finder']('uglifyjs', 'uglifyjs_binary'); + + if (null === $uglifyJsBinary) { + throw new RuntimeException('Unable to find uglifyJs executable.'); + } + + return UglifyJsDriver::create(array('uglifyjs.binaries' => $uglifyJsBinary), $app['monolog']); }); } diff --git a/lib/Alchemy/Phrasea/Core/Provider/LessBuilderServiceProvider.php b/lib/Alchemy/Phrasea/Core/CLIProvider/LessBuilderServiceProvider.php similarity index 89% rename from lib/Alchemy/Phrasea/Core/Provider/LessBuilderServiceProvider.php rename to lib/Alchemy/Phrasea/Core/CLIProvider/LessBuilderServiceProvider.php index 416c88fb7d..8b3f866428 100644 --- a/lib/Alchemy/Phrasea/Core/Provider/LessBuilderServiceProvider.php +++ b/lib/Alchemy/Phrasea/Core/CLIProvider/LessBuilderServiceProvider.php @@ -9,11 +9,12 @@ * file that was distributed with this source code. */ -namespace Alchemy\Phrasea\Core\Provider; +namespace Alchemy\Phrasea\Core\CLIProvider; use Silex\Application; use Silex\ServiceProviderInterface; use Alchemy\Phrasea\Utilities\Less\Builder as LessBuilder; +use Alchemy\Phrasea\Utilities\Less\Compiler as LessCompiler; class LessBuilderServiceProvider implements ServiceProviderInterface { @@ -47,6 +48,10 @@ class LessBuilderServiceProvider implements ServiceProviderInterface ); }); + $app['phraseanet.less-compiler'] = $app->share(function($app) { + return new LessCompiler($app['filesystem'], $app['driver.recess']); + }); + $app['phraseanet.less-builder'] = $app->share(function($app) { return new LessBuilder($app['phraseanet.less-compiler'], $app['filesystem']); }); diff --git a/lib/Alchemy/Phrasea/Core/Provider/LessCompilerServiceProvider.php b/lib/Alchemy/Phrasea/Core/Provider/LessCompilerServiceProvider.php deleted file mode 100644 index 50700dbf01..0000000000 --- a/lib/Alchemy/Phrasea/Core/Provider/LessCompilerServiceProvider.php +++ /dev/null @@ -1,30 +0,0 @@ -share(function($app) { - return LessCompiler::create($app); - }); - } - - public function boot(Application $app) - { - } -} diff --git a/lib/Alchemy/Phrasea/Utilities/Less/Compiler.php b/lib/Alchemy/Phrasea/Utilities/Less/Compiler.php index 9344b19600..df9bcd6a0a 100644 --- a/lib/Alchemy/Phrasea/Utilities/Less/Compiler.php +++ b/lib/Alchemy/Phrasea/Utilities/Less/Compiler.php @@ -11,8 +11,7 @@ namespace Alchemy\Phrasea\Utilities\Less; -use Alchemy\Phrasea\Application; -use Alchemy\BinaryDriver\BinaryInterface; +use Alchemy\Phrasea\Command\Developer\Utils\RecessDriver; use Alchemy\BinaryDriver\Exception\ExecutionFailureException; use Alchemy\Phrasea\Exception\RuntimeException; use Symfony\Component\Filesystem\Filesystem; @@ -22,19 +21,12 @@ class Compiler private $filesystem; private $recess; - public function __construct(Filesystem $filesystem, BinaryInterface $recess) + public function __construct(Filesystem $filesystem, RecessDriver $recess) { $this->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 * diff --git a/lib/classes/databox.php b/lib/classes/databox.php index 62353a5c85..be7249dcf0 100644 --- a/lib/classes/databox.php +++ b/lib/classes/databox.php @@ -943,7 +943,7 @@ class databox extends base ) ? $type : databox_field::TYPE_STRING; $multi = isset($field['multi']) ? (Boolean) (string) $field['multi'] : false; - + $meta_struct_field = databox_field::create($this->app, $this, $fname, $multi); $meta_struct_field ->set_readonly(isset($field['readonly']) ? (string) $field['readonly'] : 0) diff --git a/lib/classes/patch/3814.php b/lib/classes/patch/3814.php index acb0dad987..a78bd54917 100644 --- a/lib/classes/patch/3814.php +++ b/lib/classes/patch/3814.php @@ -10,8 +10,6 @@ */ use Alchemy\Phrasea\Application; -use Entities\Session; -use Entities\SessionModule; class patch_3814 implements patchInterface { diff --git a/tests/Alchemy/Tests/Phrasea/Utilities/Less/RecessDriverTest.php b/tests/Alchemy/Tests/Phrasea/Command/Developper/Utils/RecessDriverTest.php similarity index 58% rename from tests/Alchemy/Tests/Phrasea/Utilities/Less/RecessDriverTest.php rename to tests/Alchemy/Tests/Phrasea/Command/Developper/Utils/RecessDriverTest.php index 0543e1b314..6b4355fcae 100644 --- a/tests/Alchemy/Tests/Phrasea/Utilities/Less/RecessDriverTest.php +++ b/tests/Alchemy/Tests/Phrasea/Command/Developper/Utils/RecessDriverTest.php @@ -1,17 +1,8 @@ getMock('Alchemy\BinaryDriver\BinaryInterface'); + $recessDriver = $this->getMockBuilder('Alchemy\Phrasea\Command\Developer\Utils\RecessDriver') + ->disableOriginalConstructor() + ->getMock(); $recessDriver->expects($this->once())->method('command'); $filesystem = $this->getMock('Symfony\Component\Filesystem\Filesystem'); @@ -30,18 +32,14 @@ class CompilerTest extends \PhraseanetPHPUnitAbstract $compiler->compile(__DIR__ . '/output.css', __FILE__); } - public function testCreate() - { - $compiler = Compiler::create(self::$DI['app']); - $this->assertInstanceOf('Alchemy\Phrasea\Utilities\Less\Compiler', $compiler); - } - - /** + /** * @expectedException Alchemy\Phrasea\Exception\RuntimeException */ public function testCompileFileNotExists() { - $recessDriver = $this->getMock('Alchemy\BinaryDriver\BinaryInterface'); + $recessDriver = $this->getMockBuilder('Alchemy\Phrasea\Command\Developer\Utils\RecessDriver') + ->disableOriginalConstructor() + ->getMock(); $filesystem = $this->getMock('Symfony\Component\Filesystem\Filesystem'); $filesystem->expects($this->once())->method('mkdir'); @@ -56,7 +54,10 @@ class CompilerTest extends \PhraseanetPHPUnitAbstract */ public function testCompileExecutionFailure() { - $recessDriver = $this->getMock('Alchemy\BinaryDriver\BinaryInterface'); + $recessDriver = $this->getMockBuilder('Alchemy\Phrasea\Command\Developer\Utils\RecessDriver') + ->disableOriginalConstructor() + ->getMock(); + $recessDriver->expects($this->once())->method('command')->will( $this->throwException(new ExecutionFailureException()) );