share(function () { return new ExecutableFinder(); }); $app['driver.binary-finder'] = $app->protect(function ($name, $configName) use ($app) { $extraDirs = array(); if (is_dir($app['root.path'] . '/node_modules')) { $extraDirs[] = $app['root.path'] . '/node_modules/.bin'; } if (!$app['phraseanet.configuration']->isSetup()) { return $app['executable-finder']->find($name, null, $extraDirs); } if (isset($app['phraseanet.configuration']['binaries'][$configName])) { return $app['phraseanet.configuration']['binaries'][$configName]; } return $app['executable-finder']->find($name, null, $extraDirs); }); $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.'); } return BowerDriver::create(array('bower.binaries' => $bowerBinary, 'timeout' => 300), $app['monolog']); }); $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.'); } return ComposerDriver::create(array('composer.binaries' => $composerBinary, 'timeout' => 300), $app['monolog']); }); $app['driver.uglifyjs'] = $app->share(function (Application $app) { $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']); }); $app['driver.grunt'] = $app->share(function (Application $app) { $gruntBinary = $app['driver.binary-finder']('grunt', 'grunt_binary'); if (null === $gruntBinary) { throw new RuntimeException('Unable to find grunt executable.'); } return GruntDriver::create(array('grunt.binaries' => $gruntBinary), $app['monolog']); }); } public function boot(Application $app) { } }