From 6d4fcbbe9a822359fe7a1736b8982b3c99940220 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Burnichon?= Date: Mon, 13 Apr 2015 17:44:44 +0200 Subject: [PATCH 1/8] Refactor SearchEngineController --- lib/Alchemy/Phrasea/Application.php | 4 +- .../Admin/SearchEngineController.php | 46 +++++++++++++++++++ .../ControllerProvider/Admin/SearchEngine.php | 34 +++++++------- .../AbstractConfigurationPanel.php | 12 ++++- .../ConfigurationPanelInterface.php | 12 ++--- .../Elastic/ConfigurationPanel.php | 17 +++---- .../Elastic/ElasticSearchEngine.php | 2 +- lib/classes/databox/descriptionStructure.php | 2 +- 8 files changed, 93 insertions(+), 36 deletions(-) create mode 100644 lib/Alchemy/Phrasea/Controller/Admin/SearchEngineController.php diff --git a/lib/Alchemy/Phrasea/Application.php b/lib/Alchemy/Phrasea/Application.php index 135424f9e6..2262fd61a8 100644 --- a/lib/Alchemy/Phrasea/Application.php +++ b/lib/Alchemy/Phrasea/Application.php @@ -12,7 +12,6 @@ namespace Alchemy\Phrasea; use Alchemy\Geonames\GeonamesServiceProvider; -use Alchemy\Phrasea\ControllerProvider\Admin\SearchEngine; use Alchemy\Phrasea\ControllerProvider\Admin\Setup; use Alchemy\Phrasea\ControllerProvider\Admin\Subdefs; use Alchemy\Phrasea\ControllerProvider\Admin\TaskManager; @@ -312,6 +311,7 @@ class Application extends SilexApplication 'Alchemy\Phrasea\ControllerProvider\Admin\Feeds' => [], 'Alchemy\Phrasea\ControllerProvider\Admin\Fields' => [], 'Alchemy\Phrasea\ControllerProvider\Admin\Root' => [], + 'Alchemy\Phrasea\ControllerProvider\Admin\SearchEngine' => [], 'Alchemy\Phrasea\ControllerProvider\Admin\Users' => [], 'Alchemy\Phrasea\ControllerProvider\Datafiles' => [], 'Alchemy\Phrasea\ControllerProvider\Lightbox' => [], @@ -623,7 +623,6 @@ class Application extends SilexApplication $this->mount('/developers/', new Developers()); $this->mount('/admin/setup', new Setup()); - $this->mount('/admin/search-engine', new SearchEngine()); $this->mount('/admin/task-manager', new TaskManager()); $this->mount('/admin/subdefs', new Subdefs()); @@ -676,6 +675,7 @@ class Application extends SilexApplication '/admin/databoxes' => 'Alchemy\Phrasea\ControllerProvider\Admin\Databoxes', '/admin/fields' => 'Alchemy\Phrasea\ControllerProvider\Admin\Fields', '/admin/publications' => 'Alchemy\Phrasea\ControllerProvider\Admin\Feeds', + '/admin/search-engine' => 'Alchemy\Phrasea\ControllerProvider\Admin\SearchEngine', '/admin/users' => 'Alchemy\Phrasea\ControllerProvider\Admin\Users', '/datafiles' => 'Alchemy\Phrasea\ControllerProvider\Datafiles', '/include/minify' => 'Alchemy\Phrasea\ControllerProvider\Minifier', diff --git a/lib/Alchemy/Phrasea/Controller/Admin/SearchEngineController.php b/lib/Alchemy/Phrasea/Controller/Admin/SearchEngineController.php new file mode 100644 index 0000000000..dabd53853c --- /dev/null +++ b/lib/Alchemy/Phrasea/Controller/Admin/SearchEngineController.php @@ -0,0 +1,46 @@ +configurationPanel = $configurationPanel; + } + + /** + * @param Request $request + * @return Response + */ + public function getConfigurationPanelAction(Request $request) + { + return $this->configurationPanel->get($request); + } + + /** + * @param Request $request + * @return Response + */ + public function postConfigurationPanelAction(Request $request) + { + return $this->configurationPanel->post($request); + } +} diff --git a/lib/Alchemy/Phrasea/ControllerProvider/Admin/SearchEngine.php b/lib/Alchemy/Phrasea/ControllerProvider/Admin/SearchEngine.php index 2d6efe97ea..a2039d6e94 100644 --- a/lib/Alchemy/Phrasea/ControllerProvider/Admin/SearchEngine.php +++ b/lib/Alchemy/Phrasea/ControllerProvider/Admin/SearchEngine.php @@ -12,34 +12,36 @@ namespace Alchemy\Phrasea\ControllerProvider\Admin; use Alchemy\Phrasea\Application as PhraseaApplication; -use Symfony\Component\HttpFoundation\Request; +use Alchemy\Phrasea\Controller\Admin\SearchEngineController; +use Silex\ControllerCollection; +use Silex\ServiceProviderInterface; use Silex\Application; use Silex\ControllerProviderInterface; -class SearchEngine implements ControllerProviderInterface +class SearchEngine implements ControllerProviderInterface, ServiceProviderInterface { + public function register(Application $app) + { + $app['controller.admin.search-engine'] = $app->share(function (PhraseaApplication $app) { + return new SearchEngineController($app); + }); + } + + public function boot(Application $app) + { + } + public function connect(Application $app) { - $app['controller.admin.search-engine'] = $this; - + /** @var ControllerCollection $controllers */ $controllers = $app['controllers_factory']; - $controllers->get('/', 'controller.admin.search-engine:getSearchEngineConfigurationPanel') + $controllers->get('/', 'controller.admin.search-engine:getConfigurationPanelAction') ->bind('admin_searchengine_get'); - $controllers->post('/', 'controller.admin.search-engine:postSearchEngineConfigurationPanel') + $controllers->post('/', 'controller.admin.search-engine:postConfigurationPanelAction') ->bind('admin_searchengine_post'); return $controllers; } - - public function getSearchEngineConfigurationPanel(PhraseaApplication $app, Request $request) - { - return $app['phraseanet.SE']->getConfigurationPanel()->get($app, $request); - } - - public function postSearchEngineConfigurationPanel(PhraseaApplication $app, Request $request) - { - return $app['phraseanet.SE']->getConfigurationPanel()->post($app, $request); - } } diff --git a/lib/Alchemy/Phrasea/SearchEngine/AbstractConfigurationPanel.php b/lib/Alchemy/Phrasea/SearchEngine/AbstractConfigurationPanel.php index 0c5eae134e..4875279693 100644 --- a/lib/Alchemy/Phrasea/SearchEngine/AbstractConfigurationPanel.php +++ b/lib/Alchemy/Phrasea/SearchEngine/AbstractConfigurationPanel.php @@ -11,18 +11,28 @@ namespace Alchemy\Phrasea\SearchEngine; +use Alchemy\Phrasea\Core\Configuration\PropertyAccess; + abstract class AbstractConfigurationPanel implements ConfigurationPanelInterface { + /** @var PropertyAccess */ protected $conf; + public function __construct(PropertyAccess $conf) + { + $this->conf = $conf; + } + /** - * {@inheritdoc} + * @param \databox[] $databoxes + * @return array */ public function getAvailableDateFields(array $databoxes) { $date_fields = []; foreach ($databoxes as $databox) { + /** @var \databox_field $field */ foreach ($databox->get_meta_structure() as $field) { if ($field->get_type() !== \databox_field::TYPE_DATE) { continue; diff --git a/lib/Alchemy/Phrasea/SearchEngine/ConfigurationPanelInterface.php b/lib/Alchemy/Phrasea/SearchEngine/ConfigurationPanelInterface.php index 6160ddcaab..5c29e1b4a2 100644 --- a/lib/Alchemy/Phrasea/SearchEngine/ConfigurationPanelInterface.php +++ b/lib/Alchemy/Phrasea/SearchEngine/ConfigurationPanelInterface.php @@ -20,20 +20,18 @@ interface ConfigurationPanelInterface /** * Handles the GET request to the configuration panel * - * @param Application $app - * @param Request $request + * @param Request $request * @return Response */ - public function get(Application $app, Request $request); + public function get(Request $request); /** * Handles the POST request to the configuration panel * - * @param Application $app - * @param Request $request + * @param Request $request * @return Response */ - public function post(Application $app, Request $request); + public function post(Request $request); /** * Return the associated search engine name @@ -60,7 +58,7 @@ interface ConfigurationPanelInterface /** * Return the names of the date fields * - * @param array $databoxes + * @param \databox[] $databoxes * @return array An array of date fields names */ public function getAvailableDateFields(array $databoxes); diff --git a/lib/Alchemy/Phrasea/SearchEngine/Elastic/ConfigurationPanel.php b/lib/Alchemy/Phrasea/SearchEngine/Elastic/ConfigurationPanel.php index fff787e866..24080dc136 100644 --- a/lib/Alchemy/Phrasea/SearchEngine/Elastic/ConfigurationPanel.php +++ b/lib/Alchemy/Phrasea/SearchEngine/Elastic/ConfigurationPanel.php @@ -18,12 +18,13 @@ use Symfony\Component\HttpFoundation\Request; class ConfigurationPanel extends AbstractConfigurationPanel { - private $searchEngine; + /** @var Application */ + private $app; - public function __construct(ElasticSearchEngine $engine, PropertyAccess $conf) + public function __construct(Application $app, PropertyAccess $conf) { - $this->searchEngine = $engine; - $this->conf = $conf; + parent::__construct($conf); + $this->app = $app; } /** @@ -37,15 +38,15 @@ class ConfigurationPanel extends AbstractConfigurationPanel /** * {@inheritdoc} */ - public function get(Application $app, Request $request) + public function get(Request $request) { - return $app['twig']->render('admin/search-engine/elastic-search.html.twig', ['configuration' => $this->getConfiguration()]); + return $this->app['twig']->render('admin/search-engine/elastic-search.html.twig', ['configuration' => $this->getConfiguration()]); } /** * {@inheritdoc} */ - public function post(Application $app, Request $request) + public function post(Request $request) { $configuration = $this->getConfiguration(); @@ -54,7 +55,7 @@ class ConfigurationPanel extends AbstractConfigurationPanel $this->saveConfiguration($configuration); - return $app->redirectPath('admin_searchengine_get'); + return $this->app->redirectPath('admin_searchengine_get'); } /** diff --git a/lib/Alchemy/Phrasea/SearchEngine/Elastic/ElasticSearchEngine.php b/lib/Alchemy/Phrasea/SearchEngine/Elastic/ElasticSearchEngine.php index 7770576496..3e0e0c51df 100644 --- a/lib/Alchemy/Phrasea/SearchEngine/Elastic/ElasticSearchEngine.php +++ b/lib/Alchemy/Phrasea/SearchEngine/Elastic/ElasticSearchEngine.php @@ -105,7 +105,7 @@ class ElasticSearchEngine implements SearchEngineInterface public function getConfigurationPanel() { if (!$this->configurationPanel) { - $this->configurationPanel = new ConfigurationPanel($this, $this->app['conf']); + $this->configurationPanel = new ConfigurationPanel($this->app, $this->app['conf']); } return $this->configurationPanel; diff --git a/lib/classes/databox/descriptionStructure.php b/lib/classes/databox/descriptionStructure.php index 5896cf882d..8aa330de25 100644 --- a/lib/classes/databox/descriptionStructure.php +++ b/lib/classes/databox/descriptionStructure.php @@ -60,7 +60,7 @@ class databox_descriptionStructure implements IteratorAggregate, Countable /** * - * @return array + * @return databox_field[] */ public function get_elements() { From 9b96e96e046ca922ea40c4b25cb8c2646e494ebc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Burnichon?= Date: Mon, 13 Apr 2015 18:03:37 +0200 Subject: [PATCH 2/8] Refactor Admin/SetupController --- lib/Alchemy/Phrasea/Application.php | 3 +- .../Controller/Admin/SetupController.php | 38 ++++++++++++++ .../ControllerProvider/Admin/Setup.php | 51 +++++++++---------- 3 files changed, 64 insertions(+), 28 deletions(-) create mode 100644 lib/Alchemy/Phrasea/Controller/Admin/SetupController.php diff --git a/lib/Alchemy/Phrasea/Application.php b/lib/Alchemy/Phrasea/Application.php index 2262fd61a8..326a91ad9f 100644 --- a/lib/Alchemy/Phrasea/Application.php +++ b/lib/Alchemy/Phrasea/Application.php @@ -312,6 +312,7 @@ class Application extends SilexApplication 'Alchemy\Phrasea\ControllerProvider\Admin\Fields' => [], 'Alchemy\Phrasea\ControllerProvider\Admin\Root' => [], 'Alchemy\Phrasea\ControllerProvider\Admin\SearchEngine' => [], + 'Alchemy\Phrasea\ControllerProvider\Admin\Setup' => [], 'Alchemy\Phrasea\ControllerProvider\Admin\Users' => [], 'Alchemy\Phrasea\ControllerProvider\Datafiles' => [], 'Alchemy\Phrasea\ControllerProvider\Lightbox' => [], @@ -622,7 +623,6 @@ class Application extends SilexApplication $this->mount('/login/', new Login()); $this->mount('/developers/', new Developers()); - $this->mount('/admin/setup', new Setup()); $this->mount('/admin/task-manager', new TaskManager()); $this->mount('/admin/subdefs', new Subdefs()); @@ -676,6 +676,7 @@ class Application extends SilexApplication '/admin/fields' => 'Alchemy\Phrasea\ControllerProvider\Admin\Fields', '/admin/publications' => 'Alchemy\Phrasea\ControllerProvider\Admin\Feeds', '/admin/search-engine' => 'Alchemy\Phrasea\ControllerProvider\Admin\SearchEngine', + '/admin/setup' => 'Alchemy\Phrasea\ControllerProvider\Admin\Setup', '/admin/users' => 'Alchemy\Phrasea\ControllerProvider\Admin\Users', '/datafiles' => 'Alchemy\Phrasea\ControllerProvider\Datafiles', '/include/minify' => 'Alchemy\Phrasea\ControllerProvider\Minifier', diff --git a/lib/Alchemy/Phrasea/Controller/Admin/SetupController.php b/lib/Alchemy/Phrasea/Controller/Admin/SetupController.php new file mode 100644 index 0000000000..bab5d26ed1 --- /dev/null +++ b/lib/Alchemy/Phrasea/Controller/Admin/SetupController.php @@ -0,0 +1,38 @@ +app['registry.manipulator']; + $form = $manipulator->createForm($this->app['conf']); + + if ('POST' === $request->getMethod()) { + $form->handleRequest($request); + if ($form->isValid()) { + $this->app['conf']->set('registry', $manipulator->getRegistryData($form)); + + return $this->app->redirectPath('setup_display_globals'); + } + } + + return $this->render('admin/setup.html.twig', [ + 'form' => $form->createView(), + ]); + } +} diff --git a/lib/Alchemy/Phrasea/ControllerProvider/Admin/Setup.php b/lib/Alchemy/Phrasea/ControllerProvider/Admin/Setup.php index 58694a7287..3767efc1f8 100644 --- a/lib/Alchemy/Phrasea/ControllerProvider/Admin/Setup.php +++ b/lib/Alchemy/Phrasea/ControllerProvider/Admin/Setup.php @@ -11,45 +11,42 @@ namespace Alchemy\Phrasea\ControllerProvider\Admin; -use Alchemy\Phrasea\Application; -use Silex\Application as SilexApplication; +use Alchemy\Phrasea\Application as PhraseaApplication; +use Alchemy\Phrasea\Controller\Admin\SetupController; +use Alchemy\Phrasea\Security\Firewall; +use Silex\Application; +use Silex\ControllerCollection; use Silex\ControllerProviderInterface; -use Symfony\Component\HttpFoundation\Request; +use Silex\ServiceProviderInterface; -class Setup implements ControllerProviderInterface +class Setup implements ControllerProviderInterface, ServiceProviderInterface { - public function connect(SilexApplication $app) + public function register(Application $app) { - $app['controller.admin.setup'] = $this; + $app['controller.admin.setup'] = $app->share(function (PhraseaApplication $app) { + return new SetupController($app); + }); + } + public function boot(Application $app) + { + } + + public function connect(Application $app) + { + /** @var ControllerCollection $controllers */ $controllers = $app['controllers_factory']; - $controllers->before(function (Request $request) use ($app) { - $app['firewall']->requireAdmin(); + /** @var Firewall $firewall */ + $firewall = $app['firewall']; + $controllers->before(function () use ($firewall) { + $firewall->requireAdmin(); }); - $controllers->match('/', 'controller.admin.setup:getGlobals') + $controllers->match('/', 'controller.admin.setup:submitGlobalsAction') ->bind('setup_display_globals') ->method('GET|POST'); return $controllers; } - - public function getGlobals(Application $app, Request $request) - { - $form = $app['registry.manipulator']->createForm($app['conf']); - - if ('POST' === $request->getMethod()) { - $form->bind($request); - if ($form->isValid()) { - $app['conf']->set('registry', $app['registry.manipulator']->getRegistryData($form)); - - return $app->redirectPath('setup_display_globals'); - } - } - - return $app['twig']->render('admin/setup.html.twig', [ - 'form' => $form->createView(), - ]); - } } From 8136f06a54bc4411d4880d95df1485609eeffb3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Burnichon?= Date: Mon, 13 Apr 2015 18:25:28 +0200 Subject: [PATCH 3/8] Refactor SubdefsController --- lib/Alchemy/Phrasea/Application.php | 5 +- .../Controller/Admin/SubdefsController.php | 118 ++++++++++++++++++ .../ControllerProvider/Admin/Subdefs.php | 118 ++++-------------- 3 files changed, 145 insertions(+), 96 deletions(-) create mode 100644 lib/Alchemy/Phrasea/Controller/Admin/SubdefsController.php diff --git a/lib/Alchemy/Phrasea/Application.php b/lib/Alchemy/Phrasea/Application.php index 326a91ad9f..1daa78fea2 100644 --- a/lib/Alchemy/Phrasea/Application.php +++ b/lib/Alchemy/Phrasea/Application.php @@ -12,8 +12,6 @@ namespace Alchemy\Phrasea; use Alchemy\Geonames\GeonamesServiceProvider; -use Alchemy\Phrasea\ControllerProvider\Admin\Setup; -use Alchemy\Phrasea\ControllerProvider\Admin\Subdefs; use Alchemy\Phrasea\ControllerProvider\Admin\TaskManager; use Alchemy\Phrasea\ControllerProvider\Client\Root as ClientRoot; use Alchemy\Phrasea\ControllerProvider\Prod\BasketController; @@ -313,6 +311,7 @@ class Application extends SilexApplication 'Alchemy\Phrasea\ControllerProvider\Admin\Root' => [], 'Alchemy\Phrasea\ControllerProvider\Admin\SearchEngine' => [], 'Alchemy\Phrasea\ControllerProvider\Admin\Setup' => [], + 'Alchemy\Phrasea\ControllerProvider\Admin\Subdefs' => [], 'Alchemy\Phrasea\ControllerProvider\Admin\Users' => [], 'Alchemy\Phrasea\ControllerProvider\Datafiles' => [], 'Alchemy\Phrasea\ControllerProvider\Lightbox' => [], @@ -624,7 +623,6 @@ class Application extends SilexApplication $this->mount('/developers/', new Developers()); $this->mount('/admin/task-manager', new TaskManager()); - $this->mount('/admin/subdefs', new Subdefs()); $this->mount('/client/', new ClientRoot()); @@ -677,6 +675,7 @@ class Application extends SilexApplication '/admin/publications' => 'Alchemy\Phrasea\ControllerProvider\Admin\Feeds', '/admin/search-engine' => 'Alchemy\Phrasea\ControllerProvider\Admin\SearchEngine', '/admin/setup' => 'Alchemy\Phrasea\ControllerProvider\Admin\Setup', + '/admin/subdefs' => 'Alchemy\Phrasea\ControllerProvider\Admin\Subdefs', '/admin/users' => 'Alchemy\Phrasea\ControllerProvider\Admin\Users', '/datafiles' => 'Alchemy\Phrasea\ControllerProvider\Datafiles', '/include/minify' => 'Alchemy\Phrasea\ControllerProvider\Minifier', diff --git a/lib/Alchemy/Phrasea/Controller/Admin/SubdefsController.php b/lib/Alchemy/Phrasea/Controller/Admin/SubdefsController.php new file mode 100644 index 0000000000..00cbd3969e --- /dev/null +++ b/lib/Alchemy/Phrasea/Controller/Admin/SubdefsController.php @@ -0,0 +1,118 @@ +findDataboxById((int) $sbas_id); + + return $this->render('admin/subdefs.html.twig', [ + 'databox' => $databox, + 'subdefs' => $databox->get_subdef_structure() + ]); + } + + /** + * @param Request $request + * @param int $sbas_id + * @return Response + * @throws \Exception + */ + function changeSubdefsAction(Request $request, $sbas_id) { + $delete_subdef = $request->request->get('delete_subdef'); + $toadd_subdef = $request->request->get('add_subdef'); + $Parmsubdefs = $request->request->get('subdefs', []); + + $databox = $this->findDataboxById((int) $sbas_id); + + $add_subdef = ['class' => null, 'name' => null, 'group' => null]; + foreach ($add_subdef as $k => $v) { + if (!isset($toadd_subdef[$k]) || trim($toadd_subdef[$k]) === '') { + unset($add_subdef[$k]); + } else { + $add_subdef[$k] = $toadd_subdef[$k]; + } + } + + if ($delete_subdef) { + $delete_subef = explode('_', $delete_subdef, 2); + $group = $delete_subef[0]; + $name = $delete_subef[1]; + $subdefs = $databox->get_subdef_structure(); + $subdefs->delete_subdef($group, $name); + } elseif (count($add_subdef) === 3) { + $subdefs = $databox->get_subdef_structure(); + + $group = $add_subdef['group']; + /** @var \unicode $unicode */ + $unicode = $this->app['unicode']; + $name = $unicode->remove_nonazAZ09($add_subdef['name'], false); + $class = $add_subdef['class']; + + $subdefs->add_subdef($group, $name, $class); + } else { + $subdefs = $databox->get_subdef_structure(); + + foreach ($Parmsubdefs as $post_sub) { + $options = []; + + $post_sub_ex = explode('_', $post_sub, 2); + + $group = $post_sub_ex[0]; + $name = $post_sub_ex[1]; + + $class = $request->request->get($post_sub . '_class'); + $downloadable = $request->request->get($post_sub . '_downloadable'); + + $defaults = ['path', 'meta', 'mediatype']; + + foreach ($defaults as $def) { + $parm_loc = $request->request->get($post_sub . '_' . $def); + + if ($def == 'meta' && !$parm_loc) { + $parm_loc = "no"; + } + + $options[$def] = $parm_loc; + } + + $mediatype = $request->request->get($post_sub . '_mediatype'); + $media = $request->request->get($post_sub . '_' . $mediatype, []); + + foreach ($media as $option => $value) { + + if ($option == 'resolution' && $mediatype == 'image') { + $option = 'dpi'; + } + + $options[$option] = $value; + } + + $labels = $request->request->get($post_sub . '_label', []); + + $subdefs->set_subdef($group, $name, $class, $downloadable, $options, $labels); + } + } + + return $this->app->redirectPath('admin_subdefs_subdef', [ + 'sbas_id' => $databox->get_sbas_id(), + ]); + } +} diff --git a/lib/Alchemy/Phrasea/ControllerProvider/Admin/Subdefs.php b/lib/Alchemy/Phrasea/ControllerProvider/Admin/Subdefs.php index e51bd45020..14d5c4bfb8 100644 --- a/lib/Alchemy/Phrasea/ControllerProvider/Admin/Subdefs.php +++ b/lib/Alchemy/Phrasea/ControllerProvider/Admin/Subdefs.php @@ -11,115 +11,47 @@ namespace Alchemy\Phrasea\ControllerProvider\Admin; +use Alchemy\Phrasea\Application as PhraseaApplication; +use Alchemy\Phrasea\Controller\Admin\SubdefsController; +use Alchemy\Phrasea\Security\Firewall; use Silex\Application; +use Silex\ControllerCollection; use Silex\ControllerProviderInterface; +use Silex\ServiceProviderInterface; use Symfony\Component\HttpFoundation\Request; -class Subdefs implements ControllerProviderInterface +class Subdefs implements ControllerProviderInterface, ServiceProviderInterface { + public function register(Application $app) + { + $app['controller.admin.subdefs'] = $app->share(function (PhraseaApplication $app) { + return new SubdefsController($app); + }); + } + + public function boot(Application $app) + { + } + public function connect(Application $app) { - $app['controller.admin.subdefs'] = $this; - + /** @var ControllerCollection $controllers */ $controllers = $app['controllers_factory']; - $app['firewall']->addMandatoryAuthentication($controllers); + /** @var Firewall $firewall */ + $firewall = $app['firewall']; + $firewall->addMandatoryAuthentication($controllers); - $controllers->before(function (Request $request) use ($app) { - $app['firewall']->requireAccessToModule('admin') + $controllers->before(function (Request $request) use ($firewall) { + $firewall->requireAccessToModule('admin') ->requireRightOnSbas($request->attributes->get('sbas_id'), 'bas_modify_struct'); }); - $controllers->get('/{sbas_id}/', function (Application $app, $sbas_id) { - $databox = $app['phraseanet.appbox']->get_databox((int) $sbas_id); - - return $app['twig']->render('admin/subdefs.html.twig', [ - 'databox' => $databox, - 'subdefs' => $databox->get_subdef_structure() - ]); - }) + $controllers->get('/{sbas_id}/', 'controller.admin.subdefs:indexAction') ->bind('admin_subdefs_subdef') ->assert('sbas_id', '\d+'); - $controllers->post('/{sbas_id}/', function (Application $app, Request $request, $sbas_id) { - $delete_subdef = $request->request->get('delete_subdef'); - $toadd_subdef = $request->request->get('add_subdef'); - $Parmsubdefs = $request->request->get('subdefs', []); - - $databox = $app['phraseanet.appbox']->get_databox((int) $sbas_id); - - $add_subdef = ['class' => null, 'name' => null, 'group' => null]; - foreach ($add_subdef as $k => $v) { - if (!isset($toadd_subdef[$k]) || trim($toadd_subdef[$k]) === '') - unset($add_subdef[$k]); - else - $add_subdef[$k] = $toadd_subdef[$k]; - } - - if ($delete_subdef) { - - $delete_subef = explode('_', $delete_subdef, 2); - $group = $delete_subef[0]; - $name = $delete_subef[1]; - $subdefs = $databox->get_subdef_structure(); - $subdefs->delete_subdef($group, $name); - } elseif (count($add_subdef) === 3) { - - $subdefs = $databox->get_subdef_structure(); - - $group = $add_subdef['group']; - $name = $app['unicode']->remove_nonazAZ09($add_subdef['name'], false); - $class = $add_subdef['class']; - - $subdefs->add_subdef($group, $name, $class); - } else { - - $subdefs = $databox->get_subdef_structure(); - - foreach ($Parmsubdefs as $post_sub) { - - $options = []; - - $post_sub_ex = explode('_', $post_sub, 2); - - $group = $post_sub_ex[0]; - $name = $post_sub_ex[1]; - - $class = $request->request->get($post_sub . '_class'); - $downloadable = $request->request->get($post_sub . '_downloadable'); - - $defaults = ['path', 'meta', 'mediatype']; - - foreach ($defaults as $def) { - $parm_loc = $request->request->get($post_sub . '_' . $def); - - if ($def == 'meta' && !$parm_loc) { - $parm_loc = "no"; - } - - $options[$def] = $parm_loc; - } - - $mediatype = $request->request->get($post_sub . '_mediatype'); - $media = $request->request->get($post_sub . '_' . $mediatype, []); - - foreach ($media as $option => $value) { - - if ($option == 'resolution' && $mediatype == 'image') { - $option = 'dpi'; - } - - $options[$option] = $value; - } - - $labels = $request->request->get($post_sub . '_label', []); - - $subdefs->set_subdef($group, $name, $class, $downloadable, $options, $labels); - } - } - - return $app->redirectPath('admin_subdefs_subdef', ['sbas_id' => $databox->get_sbas_id()]); - }) + $controllers->post('/{sbas_id}/', 'controller.admin.subdefs:changeSubdefsAction') ->bind('admin_subdefs_subdef_update') ->assert('sbas_id', '\d+'); From 63634e81a963967cc94339d6b14799704d20778d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Burnichon?= Date: Mon, 13 Apr 2015 18:45:19 +0200 Subject: [PATCH 4/8] Bump version of phpunit --- composer.lock | 165 ++++++++++++++++++++++++-------------------------- 1 file changed, 79 insertions(+), 86 deletions(-) diff --git a/composer.lock b/composer.lock index faac22c438..e5da51f95d 100644 --- a/composer.lock +++ b/composer.lock @@ -11,15 +11,9 @@ "version": "6.0.039", "source": { "type": "git", - "url": "https://github.com/alchemy-fr/tcpdf-clone.git", + "url": "https://github.com/alchemy-fr/tcpdf-clone", "reference": "2ba0248a7187f1626df6c128750650416267f0e7" }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/alchemy-fr/tcpdf-clone/zipball/2ba0248a7187f1626df6c128750650416267f0e7", - "reference": "2ba0248a7187f1626df6c128750650416267f0e7", - "shasum": "" - }, "require": { "php": ">=5.3.0" }, @@ -66,10 +60,6 @@ "qrcode", "tcpdf" ], - "support": { - "source": "https://github.com/alchemy-fr/tcpdf-clone/tree/6.0.039", - "issues": "https://github.com/alchemy-fr/tcpdf-clone/issues" - }, "time": "2013-10-13 16:11:17" }, { @@ -113,7 +103,7 @@ "homepage": "http://www.lickmychip.com/" }, { - "name": "nlegoff", + "name": "Nicolas Le Goff", "email": "legoff.n@gmail.com" }, { @@ -1082,12 +1072,12 @@ "source": { "type": "git", "url": "https://github.com/doctrine/migrations.git", - "reference": "65978aa4e9ffca3bb632225ad8c6320077d80d85" + "reference": "efb77c10dfb75485998a843154bbc44d8124c4d1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/migrations/zipball/65978aa4e9ffca3bb632225ad8c6320077d80d85", - "reference": "65978aa4e9ffca3bb632225ad8c6320077d80d85", + "url": "https://api.github.com/repos/doctrine/migrations/zipball/efb77c10dfb75485998a843154bbc44d8124c4d1", + "reference": "efb77c10dfb75485998a843154bbc44d8124c4d1", "shasum": "" }, "require": { @@ -1132,7 +1122,7 @@ "database", "migrations" ], - "time": "2015-03-23 09:47:20" + "time": "2015-04-07 10:34:31" }, { "name": "doctrine/orm", @@ -1269,13 +1259,13 @@ "version": "v1.0.0", "source": { "type": "git", - "url": "https://github.com/igorw/evenement.git", - "reference": "fa966683e7df3e5dd5929d984a44abfbd6bafe8d" + "url": "https://github.com/igorw/evenement", + "reference": "v1.0.0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/igorw/evenement/zipball/fa966683e7df3e5dd5929d984a44abfbd6bafe8d", - "reference": "fa966683e7df3e5dd5929d984a44abfbd6bafe8d", + "url": "https://github.com/igorw/evenement/zipball/v1.0.0", + "reference": "v1.0.0", "shasum": "" }, "require": { @@ -1302,19 +1292,19 @@ "keywords": [ "event-dispatcher" ], - "time": "2012-05-30 15:01:08" + "time": "2012-05-30 08:01:08" }, { "name": "facebook/php-sdk", "version": "v3.2.3", "source": { "type": "git", - "url": "https://github.com/facebookarchive/facebook-php-sdk.git", + "url": "https://github.com/facebook/facebook-php-sdk.git", "reference": "6714042fa2f5979d4c64c7d11fb4bcab16bdf6cb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/facebookarchive/facebook-php-sdk/zipball/6714042fa2f5979d4c64c7d11fb4bcab16bdf6cb", + "url": "https://api.github.com/repos/facebook/facebook-php-sdk/zipball/6714042fa2f5979d4c64c7d11fb4bcab16bdf6cb", "reference": "6714042fa2f5979d4c64c7d11fb4bcab16bdf6cb", "shasum": "" }, @@ -1348,7 +1338,6 @@ "facebook", "sdk" ], - "abandoned": "facebook/php-sdk-v4", "time": "2013-11-19 23:11:14" }, { @@ -3046,7 +3035,7 @@ ], "authors": [ { - "name": "Steve Clay", + "name": "Stephen Clay", "email": "steve@mrclay.org", "homepage": "http://www.mrclay.org/", "role": "Developer" @@ -3232,21 +3221,21 @@ "source": { "type": "git", "url": "https://github.com/romainneutron/Imagine-Silex-Service-Provider.git", - "reference": "a8a7862ae90419f2b23746cd8436c2310e4eb084" + "reference": "0.1.2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/romainneutron/Imagine-Silex-Service-Provider/zipball/a8a7862ae90419f2b23746cd8436c2310e4eb084", - "reference": "a8a7862ae90419f2b23746cd8436c2310e4eb084", + "url": "https://api.github.com/repos/romainneutron/Imagine-Silex-Service-Provider/zipball/0.1.2", + "reference": "0.1.2", "shasum": "" }, "require": { "imagine/imagine": "*", "php": ">=5.3.3", - "silex/silex": "~1.0" + "silex/silex": ">=1.0,<2.0" }, "require-dev": { - "symfony/browser-kit": "~2.0" + "symfony/browser-kit": ">=2.0,<3.0" }, "type": "library", "autoload": { @@ -3718,7 +3707,7 @@ "metadata" ], "support": { - "source": "https://github.com/alchemy-fr/PHPExiftool/tree/dev" + "source": "https://github.com/alchemy-fr/PHPExiftool/tree/0.4.1-mwg-metadata-copy" }, "time": "2014-10-08 16:09:02" }, @@ -3927,12 +3916,12 @@ "source": { "type": "git", "url": "https://github.com/Roave/SecurityAdvisories.git", - "reference": "1fe4be09c2f44aace9595e6af383e51a6ba4c819" + "reference": "739e965e42ab51361a3b70396557b05157798626" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/1fe4be09c2f44aace9595e6af383e51a6ba4c819", - "reference": "1fe4be09c2f44aace9595e6af383e51a6ba4c819", + "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/739e965e42ab51361a3b70396557b05157798626", + "reference": "739e965e42ab51361a3b70396557b05157798626", "shasum": "" }, "conflict": { @@ -3941,23 +3930,25 @@ "doctrine/doctrine-module": "<=0.7.1|<=0.7.1", "doctrine/orm": ">=2.0.0,<2.0.3", "dompdf/dompdf": ">=0.6.0,<0.6.1", + "firebase/php-jwt": "<2.0.0", "friendsofsymfony/rest-bundle": ">=1.2.0,<1.2.2", "friendsofsymfony/user-bundle": ">=1.2.0,<1.2.1|>=1.2.0,<1.2.4|>=1.2.0,<1.3.0|>=1.3.0,<1.3.5|>=1.2.0,<1.2.5|>=1.3.0,<1.3.3", "illuminate/auth": ">=4.0.0,<4.0.99|>=4.1.0,<4.1.26", "illuminate/database": ">=4.0.0,<4.0.99|>=4.1.0,<4.1.29", "laravel/framework": ">=4.0.0,<4.0.99|>=4.1.0,<4.1.26|>=4.0.0,<4.0.99|>=4.1.0,<4.1.29", "monolog/monolog": ">=1.8.0,<1.12.0", + "namshi/jose": "<1.1.2|<2.0.3|<2.2.0", "sabre/dav": ">=1.6.0,<1.6.9|>=1.7.0,<1.7.7|>=1.8.0,<1.8.5", "socalnick/scn-social-auth": "<1.15.2", "swiftmailer/swiftmailer": ">=4.0.0,<4.99.99|>=5.0.0,<5.2.1", "symfony/dependency-injection": ">=2.0.0,<2.0.17", "symfony/framework-bundle": ">=2.0.0,<2.1.0|>=2.1.0,<2.2.0|>=2.2.0,<2.3.0|>=2.3.0,<2.3.18|>=2.4.0,<2.4.8|>=2.5.0,<2.5.2", - "symfony/http-foundation": ">=2.0.0,<2.0.19|>=2.1.0,<2.1.4|>=2.0.0,<2.0.19|>=2.0.0,<2.0.24|>=2.1.0,<2.1.12|>=2.2.0,<2.2.5|>=2.3.0,<2.3.3|>=2.0.0,<2.1.0|>=2.1.0,<2.2.0|>=2.2.0,<2.3.0|>=2.3.0,<2.3.19|>=2.4.0,<2.4.9|>=2.5.0,<2.5.4|>=2.0.0,<2.1.0|>=2.1.0,<2.2.0|>=2.2.0,<2.3.0|>=2.3.0,<2.3.19|>=2.4.0,<2.4.9|>=2.5.0,<2.5.4", - "symfony/http-kernel": ">=2.0.0,<2.1.0|>=2.1.0,<2.2.0|>=2.2.0,<2.3.0|>=2.3.0,<2.3.19|>=2.4.0,<2.4.9|>=2.5.0,<2.5.4", + "symfony/http-foundation": ">=2.0.0,<2.0.19|>=2.1.0,<2.1.4|>=2.0.0,<2.0.19|>=2.0.0,<2.0.24|>=2.1.0,<2.1.12|>=2.2.0,<2.2.5|>=2.3.0,<2.3.3|>=2.0.0,<2.1.0|>=2.1.0,<2.2.0|>=2.2.0,<2.3.0|>=2.3.0,<2.3.19|>=2.4.0,<2.4.9|>=2.5.0,<2.5.4|>=2.0.0,<2.1.0|>=2.1.0,<2.2.0|>=2.2.0,<2.3.0|>=2.3.0,<2.3.19|>=2.4.0,<2.4.9|>=2.5.0,<2.5.4|>=2.0.0,<2.1.0|>=2.1.0,<2.2.0|>=2.2.0,<2.3.0|>=2.3.0,<2.3.27|>=2.4.0,<2.5.0|>=2.5.0,<2.5.11|>=2.6.0,<2.6.6", + "symfony/http-kernel": ">=2.0.0,<2.1.0|>=2.1.0,<2.2.0|>=2.2.0,<2.3.0|>=2.3.0,<2.3.19|>=2.4.0,<2.4.9|>=2.5.0,<2.5.4|>=2.0.0,<2.1.0|>=2.1.0,<2.2.0|>=2.2.0,<2.3.0|>=2.3.0,<2.3.27|>=2.4.0,<2.5.0|>=2.5.0,<2.5.11|>=2.6.0,<2.6.6", "symfony/routing": ">=2.0.0,<2.0.17|>=2.0.0,<2.0.19", "symfony/security": ">=2.0.0,<2.0.19|>=2.0.0,<2.0.25|>=2.1.0,<2.1.13|>=2.2.0,<2.2.9|>=2.3.0,<2.3.6", "symfony/serializer": ">=2.0.0,<2.0.11", - "symfony/symfony": ">=2.0.0,<2.0.6|>=2.0.0,<2.0.11|>=2.0.0,<2.0.17|>=2.0.0,<2.0.19|>=2.1.0,<2.1.4|>=2.0.0,<2.0.19|>=2.0.0,<2.0.20|>=2.1.0,<2.1.5|>=2.0.0,<2.0.22|>=2.0.0,<2.0.22|>=2.1.0,<2.1.7|>=2.0.0,<2.0.24|>=2.1.0,<2.1.12|>=2.2.0,<2.2.5|>=2.3.0,<2.3.3|>=2.0.0,<2.0.24|>=2.1.0,<2.1.12|>=2.2.0,<2.2.5|>=2.3.0,<2.3.3|>=2.0.0,<2.0.25|>=2.1.0,<2.1.13|>=2.2.0,<2.2.9|>=2.3.0,<2.3.6|>=2.0.0,<2.1.0|>=2.1.0,<2.2.0|>=2.2.0,<2.3.0|>=2.3.0,<2.3.19|>=2.4.0,<2.4.9|>=2.5.0,<2.5.4|>=2.0.0,<2.1.0|>=2.1.0,<2.2.0|>=2.2.0,<2.3.0|>=2.3.0,<2.3.19|>=2.4.0,<2.4.9|>=2.5.0,<2.5.4|>=2.0.0,<2.1.0|>=2.1.0,<2.2.0|>=2.2.0,<2.3.0|>=2.3.0,<2.3.19|>=2.4.0,<2.4.9|>=2.5.0,<2.5.4|>=2.0.0,<2.1.0|>=2.1.0,<2.2.0|>=2.2.0,<2.3.0|>=2.3.0,<2.3.19|>=2.4.0,<2.4.9|>=2.5.0,<2.5.4|>=2.0.0,<2.1.0|>=2.1.0,<2.2.0|>=2.2.0,<2.3.0|>=2.3.0,<2.3.19|>=2.4.0,<2.4.9|>=2.5.0,<2.5.4", + "symfony/symfony": ">=2.0.0,<2.0.6|>=2.0.0,<2.0.11|>=2.0.0,<2.0.17|>=2.0.0,<2.0.19|>=2.1.0,<2.1.4|>=2.0.0,<2.0.19|>=2.0.0,<2.0.20|>=2.1.0,<2.1.5|>=2.0.0,<2.0.22|>=2.0.0,<2.0.22|>=2.1.0,<2.1.7|>=2.0.0,<2.0.24|>=2.1.0,<2.1.12|>=2.2.0,<2.2.5|>=2.3.0,<2.3.3|>=2.0.0,<2.0.24|>=2.1.0,<2.1.12|>=2.2.0,<2.2.5|>=2.3.0,<2.3.3|>=2.0.0,<2.0.25|>=2.1.0,<2.1.13|>=2.2.0,<2.2.9|>=2.3.0,<2.3.6|>=2.0.0,<2.1.0|>=2.1.0,<2.2.0|>=2.2.0,<2.3.0|>=2.3.0,<2.3.19|>=2.4.0,<2.4.9|>=2.5.0,<2.5.4|>=2.0.0,<2.1.0|>=2.1.0,<2.2.0|>=2.2.0,<2.3.0|>=2.3.0,<2.3.19|>=2.4.0,<2.4.9|>=2.5.0,<2.5.4|>=2.0.0,<2.1.0|>=2.1.0,<2.2.0|>=2.2.0,<2.3.0|>=2.3.0,<2.3.19|>=2.4.0,<2.4.9|>=2.5.0,<2.5.4|>=2.0.0,<2.1.0|>=2.1.0,<2.2.0|>=2.2.0,<2.3.0|>=2.3.0,<2.3.19|>=2.4.0,<2.4.9|>=2.5.0,<2.5.4|>=2.0.0,<2.1.0|>=2.1.0,<2.2.0|>=2.2.0,<2.3.0|>=2.3.0,<2.3.19|>=2.4.0,<2.4.9|>=2.5.0,<2.5.4|>=2.0.0,<2.1.0|>=2.1.0,<2.2.0|>=2.2.0,<2.3.0|>=2.3.0,<2.3.27|>=2.4.0,<2.5.0|>=2.5.0,<2.5.11|>=2.6.0,<2.6.6|>=2.0.0,<2.1.0|>=2.1.0,<2.2.0|>=2.2.0,<2.3.0|>=2.3.0,<2.3.27|>=2.4.0,<2.5.0|>=2.5.0,<2.5.11|>=2.6.0,<2.6.6", "symfony/translation": ">=2.0.0,<2.0.17", "symfony/validator": ">=2.0.0,<2.0.17|>=2.0.0,<2.0.24|>=2.1.0,<2.1.12|>=2.2.0,<2.2.5|>=2.3.0,<2.3.3", "symfony/web-profiler-bundle": ">=2.0.0,<2.1.0|>=2.1.0,<2.2.0|>=2.2.0,<2.3.0|>=2.3.0,<2.3.19|>=2.4.0,<2.4.9|>=2.5.0,<2.5.4", @@ -3995,7 +3986,7 @@ } ], "description": "Prevents installation of composer packages with known security vulnerabilities: no API, simply require it", - "time": "2015-03-13 23:54:02" + "time": "2015-04-03 12:25:49" }, { "name": "silex/silex", @@ -4208,7 +4199,7 @@ }, { "name": "Phraseanet Team", - "email": "info@alchemy.fr", + "email": "support@alchemy.fr", "homepage": "http://www.phraseanet.com/" } ], @@ -4845,16 +4836,16 @@ }, { "name": "phpunit/php-code-coverage", - "version": "2.0.15", + "version": "2.0.16", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "34cc484af1ca149188d0d9e91412191e398e0b67" + "reference": "934fd03eb6840508231a7f73eb8940cf32c3b66c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/34cc484af1ca149188d0d9e91412191e398e0b67", - "reference": "34cc484af1ca149188d0d9e91412191e398e0b67", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/934fd03eb6840508231a7f73eb8940cf32c3b66c", + "reference": "934fd03eb6840508231a7f73eb8940cf32c3b66c", "shasum": "" }, "require": { @@ -4903,35 +4894,37 @@ "testing", "xunit" ], - "time": "2015-01-24 10:06:35" + "time": "2015-04-11 04:35:00" }, { "name": "phpunit/php-file-iterator", - "version": "1.3.4", + "version": "1.4.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb" + "reference": "a923bb15680d0089e2316f7a4af8f437046e96bb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/acd690379117b042d1c8af1fafd61bde001bf6bb", - "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/a923bb15680d0089e2316f7a4af8f437046e96bb", + "reference": "a923bb15680d0089e2316f7a4af8f437046e96bb", "shasum": "" }, "require": { "php": ">=5.3.3" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4.x-dev" + } + }, "autoload": { "classmap": [ - "File/" + "src/" ] }, "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "" - ], "license": [ "BSD-3-Clause" ], @@ -4948,7 +4941,7 @@ "filesystem", "iterator" ], - "time": "2013-10-10 15:34:57" + "time": "2015-04-02 05:19:05" }, { "name": "phpunit/php-text-template", @@ -5040,16 +5033,16 @@ }, { "name": "phpunit/php-token-stream", - "version": "1.4.0", + "version": "1.4.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "db32c18eba00b121c145575fcbcd4d4d24e6db74" + "reference": "eab81d02569310739373308137284e0158424330" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/db32c18eba00b121c145575fcbcd4d4d24e6db74", - "reference": "db32c18eba00b121c145575fcbcd4d4d24e6db74", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/eab81d02569310739373308137284e0158424330", + "reference": "eab81d02569310739373308137284e0158424330", "shasum": "" }, "require": { @@ -5085,20 +5078,20 @@ "keywords": [ "tokenizer" ], - "time": "2015-01-17 09:51:32" + "time": "2015-04-08 04:46:07" }, { "name": "phpunit/phpunit", - "version": "4.5.1", + "version": "4.6.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "d6429b0995b24a2d9dfe5587ee3a7071c1161af4" + "reference": "163232991e652e6efed2f8470326fffa61e848e2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/d6429b0995b24a2d9dfe5587ee3a7071c1161af4", - "reference": "d6429b0995b24a2d9dfe5587ee3a7071c1161af4", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/163232991e652e6efed2f8470326fffa61e848e2", + "reference": "163232991e652e6efed2f8470326fffa61e848e2", "shasum": "" }, "require": { @@ -5110,17 +5103,17 @@ "php": ">=5.3.3", "phpspec/prophecy": "~1.3,>=1.3.1", "phpunit/php-code-coverage": "~2.0,>=2.0.11", - "phpunit/php-file-iterator": "~1.3.2", + "phpunit/php-file-iterator": "~1.4", "phpunit/php-text-template": "~1.2", - "phpunit/php-timer": "~1.0.2", + "phpunit/php-timer": "~1.0", "phpunit/phpunit-mock-objects": "~2.3", "sebastian/comparator": "~1.1", - "sebastian/diff": "~1.1", + "sebastian/diff": "~1.2", "sebastian/environment": "~1.2", "sebastian/exporter": "~1.2", "sebastian/global-state": "~1.0", "sebastian/version": "~1.0", - "symfony/yaml": "~2.0" + "symfony/yaml": "~2.1|~3.0" }, "suggest": { "phpunit/php-invoker": "~1.1" @@ -5131,7 +5124,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.5.x-dev" + "dev-master": "4.6.x-dev" } }, "autoload": { @@ -5157,7 +5150,7 @@ "testing", "xunit" ], - "time": "2015-03-29 09:24:05" + "time": "2015-04-11 05:23:21" }, { "name": "phpunit/phpunit-mock-objects", @@ -5280,16 +5273,16 @@ }, { "name": "sebastian/diff", - "version": "1.2.0", + "version": "1.3.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "5843509fed39dee4b356a306401e9dd1a931fec7" + "reference": "863df9687835c62aa423a22412d26fa2ebde3fd3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/5843509fed39dee4b356a306401e9dd1a931fec7", - "reference": "5843509fed39dee4b356a306401e9dd1a931fec7", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/863df9687835c62aa423a22412d26fa2ebde3fd3", + "reference": "863df9687835c62aa423a22412d26fa2ebde3fd3", "shasum": "" }, "require": { @@ -5301,7 +5294,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.2-dev" + "dev-master": "1.3-dev" } }, "autoload": { @@ -5328,32 +5321,32 @@ "keywords": [ "diff" ], - "time": "2014-08-15 10:29:00" + "time": "2015-02-22 15:13:53" }, { "name": "sebastian/environment", - "version": "1.2.1", + "version": "1.2.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "6e6c71d918088c251b181ba8b3088af4ac336dd7" + "reference": "5a8c7d31914337b69923db26c4221b81ff5a196e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/6e6c71d918088c251b181ba8b3088af4ac336dd7", - "reference": "6e6c71d918088c251b181ba8b3088af4ac336dd7", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/5a8c7d31914337b69923db26c4221b81ff5a196e", + "reference": "5a8c7d31914337b69923db26c4221b81ff5a196e", "shasum": "" }, "require": { "php": ">=5.3.3" }, "require-dev": { - "phpunit/phpunit": "~4.3" + "phpunit/phpunit": "~4.4" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.2.x-dev" + "dev-master": "1.3.x-dev" } }, "autoload": { @@ -5378,7 +5371,7 @@ "environment", "hhvm" ], - "time": "2014-10-25 08:00:45" + "time": "2015-01-01 10:01:08" }, { "name": "sebastian/exporter", @@ -5552,16 +5545,16 @@ }, { "name": "sebastian/version", - "version": "1.0.4", + "version": "1.0.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/version.git", - "reference": "a77d9123f8e809db3fbdea15038c27a95da4058b" + "reference": "ab931d46cd0d3204a91e1b9a40c4bc13032b58e4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/a77d9123f8e809db3fbdea15038c27a95da4058b", - "reference": "a77d9123f8e809db3fbdea15038c27a95da4058b", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/ab931d46cd0d3204a91e1b9a40c4bc13032b58e4", + "reference": "ab931d46cd0d3204a91e1b9a40c4bc13032b58e4", "shasum": "" }, "type": "library", @@ -5583,7 +5576,7 @@ ], "description": "Library that helps with managing the version number of Git-hosted PHP projects", "homepage": "https://github.com/sebastianbergmann/version", - "time": "2014-12-15 14:25:24" + "time": "2015-02-24 06:35:25" } ], "aliases": [ From 14a62fd9e8936d303fa9a605d92e18322fbf07c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Burnichon?= Date: Mon, 13 Apr 2015 19:01:37 +0200 Subject: [PATCH 5/8] Split TaskManager ControllerProvider into 2 classes --- .../Admin/TaskManagerController.php | 331 +++++++++++++++++ .../ControllerProvider/Admin/TaskManager.php | 347 ++---------------- 2 files changed, 357 insertions(+), 321 deletions(-) create mode 100644 lib/Alchemy/Phrasea/Controller/Admin/TaskManagerController.php diff --git a/lib/Alchemy/Phrasea/Controller/Admin/TaskManagerController.php b/lib/Alchemy/Phrasea/Controller/Admin/TaskManagerController.php new file mode 100644 index 0000000000..d1735630e2 --- /dev/null +++ b/lib/Alchemy/Phrasea/Controller/Admin/TaskManagerController.php @@ -0,0 +1,331 @@ +start(); + + $cmdLine = sprintf( + '%s %s %s', + $app['conf']->get(['main', 'binaries', 'php_binary']), + realpath(__DIR__ . '/../../../../../bin/console'), + 'task-manager:scheduler:run' + ); + + /** @var EventDispatcherInterface $dispatcher */ + $dispatcher = $app['dispatcher']; + $dispatcher->addListener(KernelEvents::TERMINATE, function () use ($cmdLine) { + $process = new Process($cmdLine); + $process->setTimeout(0); + $process->disableOutput(); + set_time_limit(0); + ignore_user_abort(true); + + $process->run(); + }, -1000); + + return $app->redirectPath('admin_tasks_list'); + } + + public function stopScheduler(Application $app, Request $request) + { + $app['task-manager.status']->stop(); + + /** @var LiveInformation $info */ + $info = $app['task-manager.live-information']; + $data = $info->getManager(); + if (null !== $pid = $data['process-id']) { + if (substr(php_uname(), 0, 7) == "Windows"){ + exec(sprintf('TaskKill /PID %d', $pid)); + } else { + exec(sprintf('kill %d', $pid)); + } + } + + return $app->redirectPath('admin_tasks_list'); + } + + public function getRoot(Application $app, Request $request) + { + return $app->redirectPath('admin_tasks_list'); + } + + public function getLiveInformation(Application $app, Request $request) + { + if (false === $app['phraseanet.configuration']['main']['task-manager']['enabled']) { + throw new RuntimeException('The use of the task manager is disabled on this instance.'); + } + + if ($request->getRequestFormat() !== "json") { + $app->abort(406, 'Only JSON format is accepted.'); + } + + $tasks = []; + foreach ($app['repo.tasks']->findAll() as $task) { + $tasks[$task->getId()] = $app['task-manager.live-information']->getTask($task); + } + + return $app->json([ + 'manager' => $app['task-manager.live-information']->getManager(), + 'tasks' => $tasks + ]); + } + + public function getScheduler(Application $app, Request $request) + { + if (false === $app['phraseanet.configuration']['main']['task-manager']['enabled']) { + throw new RuntimeException('The use of the task manager is disabled on this instance.'); + } + + if ($request->getRequestFormat() !== "json") { + $app->abort(406, 'Only JSON format is accepted.'); + } + + return $app->json([ + 'name' => $app->trans('Task Scheduler'), + 'configuration' => $app['task-manager.status']->getStatus(), + 'urls' => [ + 'start' => $app->path('admin_tasks_scheduler_start'), + 'stop' => $app->path('admin_tasks_scheduler_stop'), + 'log' => $app->path('admin_tasks_scheduler_log'), + ] + ]); + } + + public function getTasks(Application $app, Request $request) + { + $tasks = []; + + foreach ($app['repo.tasks']->findAll() as $task) { + $tasks[] = [ + 'id' => $task->getId(), + 'name' => $task->getName(), + 'status' => $task->getStatus() + ]; + } + + if ($request->getRequestFormat() === "json") { + foreach ($tasks as $k => $task) { + $tasks[$k]['urls'] = $this->getTaskResourceUrls($app, $task['id']); + } + + return $app->json($tasks); + } + + return $app['twig']->render('admin/task-manager/index.html.twig', [ + 'available_jobs' => $app['task-manager.available-jobs'], + 'tasks' => $tasks, + 'scheduler' => [ + 'id' => null, + 'name' => $app->trans('Task Scheduler'), + 'status' => $app['task-manager.status']->getStatus(), + ] + ]); + } + + public function postCreateTask(Application $app, Request $request) + { + try { + $job = $app['task-manager.job-factory']->create($request->request->get('job-name')); + } catch (InvalidArgumentException $e) { + $app->abort(400, $e->getMessage()); + } + + $task = $app['manipulator.task']->create( + $job->getName(), + $job->getJobId(), + $job->getEditor()->getDefaultSettings($app['conf']), + $job->getEditor()->getDefaultPeriod() + ); + + return $app->redirectPath('admin_tasks_task_show', ['task' => $task->getId()]); + } + + public function getSchedulerLog(Application $app, Request $request) + { + $logFile = $app['task-manager.log-file.factory']->forManager(); + if ($request->query->get('clr')) { + $logFile->clear(); + } + + return $app['twig']->render('admin/task-manager/log.html.twig', [ + 'logfile' => $logFile, + 'logname' => 'Scheduler', + ]); + } + + public function getTaskLog(Application $app, Request $request, Task $task) + { + $logFile = $app['task-manager.log-file.factory']->forTask($task); + if ($request->query->get('clr')) { + $logFile->clear(); + } + + return $app['twig']->render('admin/task-manager/log.html.twig', [ + 'logfile' => $logFile, + 'logname' => sprintf('%s (task id %d)', $task->getName(), $task->getId()), + ]); + } + + public function postTaskDelete(Application $app, Request $request, Task $task) + { + if (false === $app['phraseanet.configuration']['main']['task-manager']['enabled']) { + throw new RuntimeException('The use of the task manager is disabled on this instance.'); + } + + $app['manipulator.task']->delete($task); + + return $app->redirectPath('admin_tasks_list'); + } + + public function postStartTask(Application $app, Request $request, Task $task) + { + if (false === $app['phraseanet.configuration']['main']['task-manager']['enabled']) { + throw new RuntimeException('The use of the task manager is disabled on this instance.'); + } + + $app['manipulator.task']->start($task); + + return $app->redirectPath('admin_tasks_list'); + } + + public function postStopTask(Application $app, Request $request, Task $task) + { + if (false === $app['phraseanet.configuration']['main']['task-manager']['enabled']) { + throw new RuntimeException('The use of the task manager is disabled on this instance.'); + } + + $app['manipulator.task']->stop($task); + + return $app->redirectPath('admin_tasks_list'); + } + + public function postResetCrashes(Application $app, Request $request, Task $task) + { + $app['manipulator.task']->resetCrashes($task); + + return $app->json(['success' => true]); + } + + public function postSaveTask(Application $app, Request $request, Task $task) + { + if (false === $app['phraseanet.configuration']['main']['task-manager']['enabled']) { + throw new RuntimeException('The use of the task manager is disabled on this instance.'); + } + + if (!$this->doValidateXML($request->request->get('settings'))) { + return $app->json(['success' => false, 'message' => sprintf('Unable to load XML %s', $request->request->get('xml'))]); + } + + $form = $app->form(new TaskForm()); + $form->setData($task); + $form->bind($request); + if ($form->isValid()) { + $app['manipulator.task']->update($task); + + return $app->json(['success' => true]); + } + + return $app->json([ + 'success' => false, + 'message' => implode("\n", $form->getErrors()) + ]); + } + + public function postTaskFacility(Application $app, Request $request, Task $task) + { + return $app['task-manager.job-factory'] + ->create($task->getJobId()) + ->getEditor() + ->facility($app, $request); + } + + public function postXMLFromForm(Application $app, Request $request, Task $task) + { + return $app['task-manager.job-factory'] + ->create($task->getJobId()) + ->getEditor() + ->updateXMLWithRequest($request); + } + + public function getTask(Application $app, Request $request, Task $task) + { + if (false === $app['phraseanet.configuration']['main']['task-manager']['enabled']) { + throw new RuntimeException('The use of the task manager is disabled on this instance.'); + } + + if ('json' === $request->getContentType()) { + return $app->json(array_replace([ + 'id' => $task->getId(), + 'name' => $task->getName(), + 'urls' => $this->getTaskResourceUrls($app, $task->getId()) + ], + $app['task-manager.live-information']->getTask($task) + )); + } + + $editor = $app['task-manager.job-factory'] + ->create($task->getJobId()) + ->getEditor(); + + $form = $app->form(new TaskForm()); + $form->setData($task); + + return $app['twig']->render($editor->getTemplatePath(), [ + 'task' => $task, + 'form' => $form->createView(), + 'view' => 'XML', + ]); + } + + public function validateXML(Application $app, Request $request) + { + if (false === $app['phraseanet.configuration']['main']['task-manager']['enabled']) { + throw new RuntimeException('The use of the task manager is disabled on this instance.'); + } + + return $app->json(['success' => $this->doValidateXML($request->getContent())]); + } + + private function doValidateXML($string) + { + $dom = new \DOMDocument('1.0', 'UTF-8'); + $dom->strictErrorChecking = true; + + return (Boolean) @$dom->loadXML($string); + } + + private function getTaskResourceUrls(Application $app, $taskId) + { + return [ + 'show' => $app->path('admin_tasks_task_show', ['task' => $taskId]), + 'start' => $app->path('admin_tasks_task_start', ['task' => $taskId]), + 'stop' => $app->path('admin_tasks_task_stop', ['task' => $taskId]), + 'delete' => $app->path('admin_tasks_task_delete', ['task' => $taskId]), + 'log' => $app->path('admin_tasks_task_log', ['task' => $taskId]), + ]; + } +} diff --git a/lib/Alchemy/Phrasea/ControllerProvider/Admin/TaskManager.php b/lib/Alchemy/Phrasea/ControllerProvider/Admin/TaskManager.php index 83145dc8fb..2267cb9454 100644 --- a/lib/Alchemy/Phrasea/ControllerProvider/Admin/TaskManager.php +++ b/lib/Alchemy/Phrasea/ControllerProvider/Admin/TaskManager.php @@ -11,34 +11,44 @@ namespace Alchemy\Phrasea\ControllerProvider\Admin; -use Alchemy\Phrasea\Exception\InvalidArgumentException; -use Alchemy\Phrasea\Exception\RuntimeException; -use Alchemy\Phrasea\Form\TaskForm; -use Alchemy\Phrasea\Model\Entities\Task; -use Alchemy\Phrasea\TaskManager\LiveInformation; +use Alchemy\Phrasea\Controller\Admin\TaskManagerController; +use Alchemy\Phrasea\Model\Converter\TaskConverter; +use Alchemy\Phrasea\Security\Firewall; use Silex\Application; +use Silex\ControllerCollection; use Silex\ControllerProviderInterface; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\Process\Process; +use Silex\ServiceProviderInterface; -class TaskManager implements ControllerProviderInterface +class TaskManager implements ControllerProviderInterface, ServiceProviderInterface { + public function register(Application $app) + { + $app['controller.admin.task'] = $app->share(function (\Alchemy\Phrasea\Application $app) { + return new TaskManagerController($app); + }); + } + + public function boot(Application $app) + { + } + public function connect(Application $app) { - $app['controller.admin.task'] = $this; - + /** @var ControllerCollection $controllers */ $controllers = $app['controllers_factory']; - $app['firewall']->addMandatoryAuthentication($controllers); + /** @var Firewall $firewall */ + $firewall = $app['firewall']; + $firewall->addMandatoryAuthentication($controllers); $converter = function ($task) use ($app) { - return $app['converter.task']->convert($task); + /** @var TaskConverter $converter */ + $converter = $app['converter.task']; + return $converter->convert($task); }; - $controllers->before(function (Request $request) use ($app) { - $app['firewall']->requireRight('taskmanager'); + $controllers->before(function () use ($firewall) { + $firewall->requireRight('taskmanager'); }); $controllers @@ -124,309 +134,4 @@ class TaskManager implements ControllerProviderInterface return $controllers; } - - public function startScheduler(Application $app, Request $request) - { - $app['task-manager.status']->start(); - - $cmdLine = sprintf( - '%s %s %s', - $app['conf']->get(['main', 'binaries', 'php_binary']), - realpath(__DIR__ . '/../../../../../bin/console'), - 'task-manager:scheduler:run' - ); - - /** @var EventDispatcherInterface $dispatcher */ - $dispatcher = $app['dispatcher']; - $dispatcher->addListener(KernelEvents::TERMINATE, function () use ($cmdLine) { - $process = new Process($cmdLine); - $process->setTimeout(0); - $process->disableOutput(); - set_time_limit(0); - ignore_user_abort(true); - - $process->run(); - }, -1000); - - return $app->redirectPath('admin_tasks_list'); - } - - public function stopScheduler(Application $app, Request $request) - { - $app['task-manager.status']->stop(); - - /** @var LiveInformation $info */ - $info = $app['task-manager.live-information']; - $data = $info->getManager(); - if (null !== $pid = $data['process-id']) { - if (substr(php_uname(), 0, 7) == "Windows"){ - exec(sprintf('TaskKill /PID %d', $pid)); - } else { - exec(sprintf('kill %d', $pid)); - } - } - - return $app->redirectPath('admin_tasks_list'); - } - - public function getRoot(Application $app, Request $request) - { - return $app->redirectPath('admin_tasks_list'); - } - - public function getLiveInformation(Application $app, Request $request) - { - if (false === $app['phraseanet.configuration']['main']['task-manager']['enabled']) { - throw new RuntimeException('The use of the task manager is disabled on this instance.'); - } - - if ($request->getRequestFormat() !== "json") { - $app->abort(406, 'Only JSON format is accepted.'); - } - - $tasks = []; - foreach ($app['repo.tasks']->findAll() as $task) { - $tasks[$task->getId()] = $app['task-manager.live-information']->getTask($task); - } - - return $app->json([ - 'manager' => $app['task-manager.live-information']->getManager(), - 'tasks' => $tasks - ]); - } - - public function getScheduler(Application $app, Request $request) - { - if (false === $app['phraseanet.configuration']['main']['task-manager']['enabled']) { - throw new RuntimeException('The use of the task manager is disabled on this instance.'); - } - - if ($request->getRequestFormat() !== "json") { - $app->abort(406, 'Only JSON format is accepted.'); - } - - return $app->json([ - 'name' => $app->trans('Task Scheduler'), - 'configuration' => $app['task-manager.status']->getStatus(), - 'urls' => [ - 'start' => $app->path('admin_tasks_scheduler_start'), - 'stop' => $app->path('admin_tasks_scheduler_stop'), - 'log' => $app->path('admin_tasks_scheduler_log'), - ] - ]); - } - - public function getTasks(Application $app, Request $request) - { - $tasks = []; - - foreach ($app['repo.tasks']->findAll() as $task) { - $tasks[] = [ - 'id' => $task->getId(), - 'name' => $task->getName(), - 'status' => $task->getStatus() - ]; - } - - if ($request->getRequestFormat() === "json") { - foreach ($tasks as $k => $task) { - $tasks[$k]['urls'] = $this->getTaskResourceUrls($app, $task['id']); - } - - return $app->json($tasks); - } - - return $app['twig']->render('admin/task-manager/index.html.twig', [ - 'available_jobs' => $app['task-manager.available-jobs'], - 'tasks' => $tasks, - 'scheduler' => [ - 'id' => null, - 'name' => $app->trans('Task Scheduler'), - 'status' => $app['task-manager.status']->getStatus(), - ] - ]); - } - - public function postCreateTask(Application $app, Request $request) - { - try { - $job = $app['task-manager.job-factory']->create($request->request->get('job-name')); - } catch (InvalidArgumentException $e) { - $app->abort(400, $e->getMessage()); - } - - $task = $app['manipulator.task']->create( - $job->getName(), - $job->getJobId(), - $job->getEditor()->getDefaultSettings($app['conf']), - $job->getEditor()->getDefaultPeriod() - ); - - return $app->redirectPath('admin_tasks_task_show', ['task' => $task->getId()]); - } - - public function getSchedulerLog(Application $app, Request $request) - { - $logFile = $app['task-manager.log-file.factory']->forManager(); - if ($request->query->get('clr')) { - $logFile->clear(); - } - - return $app['twig']->render('admin/task-manager/log.html.twig', [ - 'logfile' => $logFile, - 'logname' => 'Scheduler', - ]); - } - - public function getTaskLog(Application $app, Request $request, Task $task) - { - $logFile = $app['task-manager.log-file.factory']->forTask($task); - if ($request->query->get('clr')) { - $logFile->clear(); - } - - return $app['twig']->render('admin/task-manager/log.html.twig', [ - 'logfile' => $logFile, - 'logname' => sprintf('%s (task id %d)', $task->getName(), $task->getId()), - ]); - } - - public function postTaskDelete(Application $app, Request $request, Task $task) - { - if (false === $app['phraseanet.configuration']['main']['task-manager']['enabled']) { - throw new RuntimeException('The use of the task manager is disabled on this instance.'); - } - - $app['manipulator.task']->delete($task); - - return $app->redirectPath('admin_tasks_list'); - } - - public function postStartTask(Application $app, Request $request, Task $task) - { - if (false === $app['phraseanet.configuration']['main']['task-manager']['enabled']) { - throw new RuntimeException('The use of the task manager is disabled on this instance.'); - } - - $app['manipulator.task']->start($task); - - return $app->redirectPath('admin_tasks_list'); - } - - public function postStopTask(Application $app, Request $request, Task $task) - { - if (false === $app['phraseanet.configuration']['main']['task-manager']['enabled']) { - throw new RuntimeException('The use of the task manager is disabled on this instance.'); - } - - $app['manipulator.task']->stop($task); - - return $app->redirectPath('admin_tasks_list'); - } - - public function postResetCrashes(Application $app, Request $request, Task $task) - { - $app['manipulator.task']->resetCrashes($task); - - return $app->json(['success' => true]); - } - - public function postSaveTask(Application $app, Request $request, Task $task) - { - if (false === $app['phraseanet.configuration']['main']['task-manager']['enabled']) { - throw new RuntimeException('The use of the task manager is disabled on this instance.'); - } - - if (!$this->doValidateXML($request->request->get('settings'))) { - return $app->json(['success' => false, 'message' => sprintf('Unable to load XML %s', $request->request->get('xml'))]); - } - - $form = $app->form(new TaskForm()); - $form->setData($task); - $form->bind($request); - if ($form->isValid()) { - $app['manipulator.task']->update($task); - - return $app->json(['success' => true]); - } - - return $app->json([ - 'success' => false, - 'message' => implode("\n", $form->getErrors()) - ]); - } - - public function postTaskFacility(Application $app, Request $request, Task $task) - { - return $app['task-manager.job-factory'] - ->create($task->getJobId()) - ->getEditor() - ->facility($app, $request); - } - - public function postXMLFromForm(Application $app, Request $request, Task $task) - { - return $app['task-manager.job-factory'] - ->create($task->getJobId()) - ->getEditor() - ->updateXMLWithRequest($request); - } - - public function getTask(Application $app, Request $request, Task $task) - { - if (false === $app['phraseanet.configuration']['main']['task-manager']['enabled']) { - throw new RuntimeException('The use of the task manager is disabled on this instance.'); - } - - if ('json' === $request->getContentType()) { - return $app->json(array_replace([ - 'id' => $task->getId(), - 'name' => $task->getName(), - 'urls' => $this->getTaskResourceUrls($app, $task->getId()) - ], - $app['task-manager.live-information']->getTask($task) - )); - } - - $editor = $app['task-manager.job-factory'] - ->create($task->getJobId()) - ->getEditor(); - - $form = $app->form(new TaskForm()); - $form->setData($task); - - return $app['twig']->render($editor->getTemplatePath(), [ - 'task' => $task, - 'form' => $form->createView(), - 'view' => 'XML', - ]); - } - - public function validateXML(Application $app, Request $request) - { - if (false === $app['phraseanet.configuration']['main']['task-manager']['enabled']) { - throw new RuntimeException('The use of the task manager is disabled on this instance.'); - } - - return $app->json(['success' => $this->doValidateXML($request->getContent())]); - } - - private function doValidateXML($string) - { - $dom = new \DOMDocument('1.0', 'UTF-8'); - $dom->strictErrorChecking = true; - - return (Boolean) @$dom->loadXML($string); - } - - private function getTaskResourceUrls(Application $app, $taskId) - { - return [ - 'show' => $app->path('admin_tasks_task_show', ['task' => $taskId]), - 'start' => $app->path('admin_tasks_task_start', ['task' => $taskId]), - 'stop' => $app->path('admin_tasks_task_stop', ['task' => $taskId]), - 'delete' => $app->path('admin_tasks_task_delete', ['task' => $taskId]), - 'log' => $app->path('admin_tasks_task_log', ['task' => $taskId]), - ]; - } } From 27f1f98dbe6d907048c96b5876fb414567fe59f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Burnichon?= Date: Mon, 13 Apr 2015 19:29:51 +0200 Subject: [PATCH 6/8] Refactor TaskManagerController --- .../Admin/TaskManagerController.php | 239 +++++++++++------- lib/Alchemy/Phrasea/Controller/Controller.php | 9 + .../Phrasea/TaskManager/Job/Factory.php | 4 + 3 files changed, 157 insertions(+), 95 deletions(-) diff --git a/lib/Alchemy/Phrasea/Controller/Admin/TaskManagerController.php b/lib/Alchemy/Phrasea/Controller/Admin/TaskManagerController.php index d1735630e2..0a3b1b4bf0 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/TaskManagerController.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/TaskManagerController.php @@ -15,28 +15,36 @@ use Alchemy\Phrasea\Exception\InvalidArgumentException; use Alchemy\Phrasea\Exception\RuntimeException; use Alchemy\Phrasea\Form\TaskForm; use Alchemy\Phrasea\Model\Entities\Task; +use Alchemy\Phrasea\Model\Manipulator\TaskManipulator; +use Alchemy\Phrasea\Model\Repositories\TaskRepository; +use Alchemy\Phrasea\TaskManager\Job\Factory; use Alchemy\Phrasea\TaskManager\LiveInformation; +use Alchemy\Phrasea\TaskManager\Log\LogFileFactory; +use Alchemy\Phrasea\TaskManager\TaskManagerStatus; use Silex\Application; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\Process\Process; class TaskManagerController extends Controller { - public function startScheduler(Application $app, Request $request) + public function startScheduler() { - $app['task-manager.status']->start(); - + /** @var TaskManagerStatus $status */ + $status = $this->app['task-manager.status']; + $status->start(); + $cmdLine = sprintf( '%s %s %s', - $app['conf']->get(['main', 'binaries', 'php_binary']), + $this->getConf()->get(['main', 'binaries', 'php_binary']), realpath(__DIR__ . '/../../../../../bin/console'), 'task-manager:scheduler:run' ); /** @var EventDispatcherInterface $dispatcher */ - $dispatcher = $app['dispatcher']; + $dispatcher = $this->app['dispatcher']; $dispatcher->addListener(KernelEvents::TERMINATE, function () use ($cmdLine) { $process = new Process($cmdLine); $process->setTimeout(0); @@ -47,15 +55,16 @@ class TaskManagerController extends Controller $process->run(); }, -1000); - return $app->redirectPath('admin_tasks_list'); + return $this->app->redirectPath('admin_tasks_list'); } - public function stopScheduler(Application $app, Request $request) + public function stopScheduler() { - $app['task-manager.status']->stop(); + /** @var TaskManagerStatus $status */ + $status = $this->app['task-manager.status']; + $status->stop(); - /** @var LiveInformation $info */ - $info = $app['task-manager.live-information']; + $info = $this->getLiveInformationRequest(); $data = $info->getManager(); if (null !== $pid = $data['process-id']) { if (substr(php_uname(), 0, 7) == "Windows"){ @@ -65,61 +74,63 @@ class TaskManagerController extends Controller } } - return $app->redirectPath('admin_tasks_list'); + return $this->app->redirectPath('admin_tasks_list'); } - public function getRoot(Application $app, Request $request) + public function getRoot() { - return $app->redirectPath('admin_tasks_list'); + return $this->app->redirectPath('admin_tasks_list'); } - public function getLiveInformation(Application $app, Request $request) + public function getLiveInformation(Request $request) { - if (false === $app['phraseanet.configuration']['main']['task-manager']['enabled']) { + if (false === $this->app['phraseanet.configuration']['main']['task-manager']['enabled']) { throw new RuntimeException('The use of the task manager is disabled on this instance.'); } if ($request->getRequestFormat() !== "json") { - $app->abort(406, 'Only JSON format is accepted.'); + $this->app->abort(406, 'Only JSON format is accepted.'); } $tasks = []; - foreach ($app['repo.tasks']->findAll() as $task) { - $tasks[$task->getId()] = $app['task-manager.live-information']->getTask($task); + /** @var Task $task */ + foreach ($this->getTaskRepository()->findAll() as $task) { + $tasks[$task->getId()] = $this->getLiveInformationRequest()->getTask($task); } - return $app->json([ - 'manager' => $app['task-manager.live-information']->getManager(), + return $this->app->json([ + 'manager' => $this->getLiveInformationRequest()->getManager(), 'tasks' => $tasks ]); } - public function getScheduler(Application $app, Request $request) + public function getScheduler(Request $request) { - if (false === $app['phraseanet.configuration']['main']['task-manager']['enabled']) { + if (false === $this->app['phraseanet.configuration']['main']['task-manager']['enabled']) { throw new RuntimeException('The use of the task manager is disabled on this instance.'); } if ($request->getRequestFormat() !== "json") { - $app->abort(406, 'Only JSON format is accepted.'); + $this->app->abort(406, 'Only JSON format is accepted.'); } - return $app->json([ - 'name' => $app->trans('Task Scheduler'), - 'configuration' => $app['task-manager.status']->getStatus(), + return $this->app->json([ + 'name' => $this->app->trans('Task Scheduler'), + 'configuration' => $this->app['task-manager.status']->getStatus(), 'urls' => [ - 'start' => $app->path('admin_tasks_scheduler_start'), - 'stop' => $app->path('admin_tasks_scheduler_stop'), - 'log' => $app->path('admin_tasks_scheduler_log'), + 'start' => $this->app->path('admin_tasks_scheduler_start'), + 'stop' => $this->app->path('admin_tasks_scheduler_stop'), + 'log' => $this->app->path('admin_tasks_scheduler_log'), ] ]); } - public function getTasks(Application $app, Request $request) + public function getTasks(Request $request) { $tasks = []; - foreach ($app['repo.tasks']->findAll() as $task) { + /** @var Task $task */ + foreach ($this->getTaskRepository()->findAll() as $task) { $tasks[] = [ 'id' => $task->getId(), 'name' => $task->getName(), @@ -129,185 +140,191 @@ class TaskManagerController extends Controller if ($request->getRequestFormat() === "json") { foreach ($tasks as $k => $task) { - $tasks[$k]['urls'] = $this->getTaskResourceUrls($app, $task['id']); + $tasks[$k]['urls'] = $this->getTaskResourceUrls($this->app, $task['id']); } - return $app->json($tasks); + return $this->app->json($tasks); } - return $app['twig']->render('admin/task-manager/index.html.twig', [ - 'available_jobs' => $app['task-manager.available-jobs'], + return $this->app['twig']->render('admin/task-manager/index.html.twig', [ + 'available_jobs' => $this->app['task-manager.available-jobs'], 'tasks' => $tasks, 'scheduler' => [ 'id' => null, - 'name' => $app->trans('Task Scheduler'), - 'status' => $app['task-manager.status']->getStatus(), + 'name' => $this->app->trans('Task Scheduler'), + 'status' => $this->app['task-manager.status']->getStatus(), ] ]); } - public function postCreateTask(Application $app, Request $request) + public function postCreateTask(Request $request) { try { - $job = $app['task-manager.job-factory']->create($request->request->get('job-name')); + /** @var Factory $factory */ + $factory = $this->app['task-manager.job-factory']; + $job = $factory->create($request->request->get('job-name')); } catch (InvalidArgumentException $e) { - $app->abort(400, $e->getMessage()); + throw new HttpException(400, $e->getMessage(), $e); } - $task = $app['manipulator.task']->create( + $task = $this->getTaskManipulator()->create( $job->getName(), $job->getJobId(), - $job->getEditor()->getDefaultSettings($app['conf']), + $job->getEditor()->getDefaultSettings($this->app['conf']), $job->getEditor()->getDefaultPeriod() ); - return $app->redirectPath('admin_tasks_task_show', ['task' => $task->getId()]); + return $this->app->redirectPath('admin_tasks_task_show', ['task' => $task->getId()]); } - public function getSchedulerLog(Application $app, Request $request) + public function getSchedulerLog(Request $request) { - $logFile = $app['task-manager.log-file.factory']->forManager(); + /** @var LogFileFactory $factory */ + $factory = $this->app['task-manager.log-file.factory']; + $logFile = $factory->forManager(); if ($request->query->get('clr')) { $logFile->clear(); } - return $app['twig']->render('admin/task-manager/log.html.twig', [ + return $this->render('admin/task-manager/log.html.twig', [ 'logfile' => $logFile, 'logname' => 'Scheduler', ]); } - public function getTaskLog(Application $app, Request $request, Task $task) + public function getTaskLog(Request $request, Task $task) { - $logFile = $app['task-manager.log-file.factory']->forTask($task); + /** @var LogFileFactory $factory */ + $factory = $this->app['task-manager.log-file.factory']; + $logFile = $factory->forTask($task); if ($request->query->get('clr')) { $logFile->clear(); } - return $app['twig']->render('admin/task-manager/log.html.twig', [ + return $this->render('admin/task-manager/log.html.twig', [ 'logfile' => $logFile, 'logname' => sprintf('%s (task id %d)', $task->getName(), $task->getId()), ]); } - public function postTaskDelete(Application $app, Request $request, Task $task) + public function postTaskDelete(Task $task) { - if (false === $app['phraseanet.configuration']['main']['task-manager']['enabled']) { + if (false === $this->app['phraseanet.configuration']['main']['task-manager']['enabled']) { throw new RuntimeException('The use of the task manager is disabled on this instance.'); } - $app['manipulator.task']->delete($task); + $this->getTaskManipulator()->delete($task); - return $app->redirectPath('admin_tasks_list'); + return $this->app->redirectPath('admin_tasks_list'); } - public function postStartTask(Application $app, Request $request, Task $task) + public function postStartTask(Task $task) { - if (false === $app['phraseanet.configuration']['main']['task-manager']['enabled']) { + if (false === $this->app['phraseanet.configuration']['main']['task-manager']['enabled']) { throw new RuntimeException('The use of the task manager is disabled on this instance.'); } - $app['manipulator.task']->start($task); + $this->getTaskManipulator()->start($task); - return $app->redirectPath('admin_tasks_list'); + return $this->app->redirectPath('admin_tasks_list'); } - public function postStopTask(Application $app, Request $request, Task $task) + public function postStopTask(Task $task) { - if (false === $app['phraseanet.configuration']['main']['task-manager']['enabled']) { + if (false === $this->app['phraseanet.configuration']['main']['task-manager']['enabled']) { throw new RuntimeException('The use of the task manager is disabled on this instance.'); } - $app['manipulator.task']->stop($task); + $this->getTaskManipulator()->stop($task); - return $app->redirectPath('admin_tasks_list'); + return $this->app->redirectPath('admin_tasks_list'); } - public function postResetCrashes(Application $app, Request $request, Task $task) + public function postResetCrashes(Task $task) { - $app['manipulator.task']->resetCrashes($task); + $this->getTaskManipulator()->resetCrashes($task); - return $app->json(['success' => true]); + return $this->app->json(['success' => true]); } - public function postSaveTask(Application $app, Request $request, Task $task) + public function postSaveTask(Request $request, Task $task) { - if (false === $app['phraseanet.configuration']['main']['task-manager']['enabled']) { + if (false === $this->app['phraseanet.configuration']['main']['task-manager']['enabled']) { throw new RuntimeException('The use of the task manager is disabled on this instance.'); } if (!$this->doValidateXML($request->request->get('settings'))) { - return $app->json(['success' => false, 'message' => sprintf('Unable to load XML %s', $request->request->get('xml'))]); + return $this->app->json(['success' => false, 'message' => sprintf('Unable to load XML %s', $request->request->get('xml'))]); } - $form = $app->form(new TaskForm()); + $form = $this->app->form(new TaskForm()); $form->setData($task); - $form->bind($request); + $form->handleRequest($request); if ($form->isValid()) { - $app['manipulator.task']->update($task); + $this->getTaskManipulator()->update($task); - return $app->json(['success' => true]); + return $this->app->json(['success' => true]); } - return $app->json([ + return $this->app->json([ 'success' => false, - 'message' => implode("\n", $form->getErrors()) + 'message' => implode("\n", iterator_to_array($form->getErrors())), ]); } - public function postTaskFacility(Application $app, Request $request, Task $task) + public function postTaskFacility(Request $request, Task $task) { - return $app['task-manager.job-factory'] + return $this->getJobFactory() ->create($task->getJobId()) ->getEditor() - ->facility($app, $request); + ->facility($this->app, $request); } - public function postXMLFromForm(Application $app, Request $request, Task $task) + public function postXMLFromForm(Request $request, Task $task) { - return $app['task-manager.job-factory'] + return $this->getJobFactory() ->create($task->getJobId()) ->getEditor() ->updateXMLWithRequest($request); } - public function getTask(Application $app, Request $request, Task $task) + public function getTask(Request $request, Task $task) { - if (false === $app['phraseanet.configuration']['main']['task-manager']['enabled']) { + if (false === $this->app['phraseanet.configuration']['main']['task-manager']['enabled']) { throw new RuntimeException('The use of the task manager is disabled on this instance.'); } if ('json' === $request->getContentType()) { - return $app->json(array_replace([ + return $this->app->json(array_replace([ 'id' => $task->getId(), 'name' => $task->getName(), - 'urls' => $this->getTaskResourceUrls($app, $task->getId()) + 'urls' => $this->getTaskResourceUrls($this->app, $task->getId()) ], - $app['task-manager.live-information']->getTask($task) + $this->getLiveInformationRequest()->getTask($task) )); } - $editor = $app['task-manager.job-factory'] + $editor = $this->getJobFactory() ->create($task->getJobId()) ->getEditor(); - $form = $app->form(new TaskForm()); + $form = $this->app->form(new TaskForm()); $form->setData($task); - return $app['twig']->render($editor->getTemplatePath(), [ + return $this->render($editor->getTemplatePath(), [ 'task' => $task, 'form' => $form->createView(), 'view' => 'XML', ]); } - public function validateXML(Application $app, Request $request) + public function validateXML(Request $request) { - if (false === $app['phraseanet.configuration']['main']['task-manager']['enabled']) { + if (false === $this->app['phraseanet.configuration']['main']['task-manager']['enabled']) { throw new RuntimeException('The use of the task manager is disabled on this instance.'); } - return $app->json(['success' => $this->doValidateXML($request->getContent())]); + return $this->app->json(['success' => $this->doValidateXML($request->getContent())]); } private function doValidateXML($string) @@ -318,14 +335,46 @@ class TaskManagerController extends Controller return (Boolean) @$dom->loadXML($string); } - private function getTaskResourceUrls(Application $app, $taskId) + private function getTaskResourceUrls($taskId) { return [ - 'show' => $app->path('admin_tasks_task_show', ['task' => $taskId]), - 'start' => $app->path('admin_tasks_task_start', ['task' => $taskId]), - 'stop' => $app->path('admin_tasks_task_stop', ['task' => $taskId]), - 'delete' => $app->path('admin_tasks_task_delete', ['task' => $taskId]), - 'log' => $app->path('admin_tasks_task_log', ['task' => $taskId]), + 'show' => $this->app->path('admin_tasks_task_show', ['task' => $taskId]), + 'start' => $this->app->path('admin_tasks_task_start', ['task' => $taskId]), + 'stop' => $this->app->path('admin_tasks_task_stop', ['task' => $taskId]), + 'delete' => $this->app->path('admin_tasks_task_delete', ['task' => $taskId]), + 'log' => $this->app->path('admin_tasks_task_log', ['task' => $taskId]), ]; } + + /** + * @return TaskRepository + */ + private function getTaskRepository() + { + return $this->app['repo.tasks']; + } + + /** + * @return LiveInformation + */ + private function getLiveInformationRequest() + { + return $this->app['task-manager.live-information']; + } + + /** + * @return TaskManipulator + */ + private function getTaskManipulator() + { + return $this->app['manipulator.task']; + } + + /** + * @return Factory + */ + private function getJobFactory() + { + return $this->app['task-manager.job-factory']; + } } diff --git a/lib/Alchemy/Phrasea/Controller/Controller.php b/lib/Alchemy/Phrasea/Controller/Controller.php index 20485505bc..a6d2935f43 100644 --- a/lib/Alchemy/Phrasea/Controller/Controller.php +++ b/lib/Alchemy/Phrasea/Controller/Controller.php @@ -13,6 +13,7 @@ namespace Alchemy\Phrasea\Controller; use Alchemy\Phrasea\Application; use Alchemy\Phrasea\Authentication\ACLProvider; use Alchemy\Phrasea\Authentication\Authenticator; +use Alchemy\Phrasea\Core\Configuration\PropertyAccess; use Alchemy\Phrasea\Model\Entities\User; use Symfony\Component\HttpFoundation\Response; @@ -110,4 +111,12 @@ class Controller { return $this->getAuthenticator()->getUser(); } + + /** + * @return PropertyAccess + */ + protected function getConf() + { + return $this->app['conf']; + } } diff --git a/lib/Alchemy/Phrasea/TaskManager/Job/Factory.php b/lib/Alchemy/Phrasea/TaskManager/Job/Factory.php index 9f2be14e73..b48a31e27d 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Job/Factory.php +++ b/lib/Alchemy/Phrasea/TaskManager/Job/Factory.php @@ -29,6 +29,10 @@ class Factory $this->translator = $translator; } + /** + * @param string $fqn + * @return JobInterface + */ public function create($fqn) { if (!class_exists($fqn)) { From e90687e4ff5163f5c6bbcac841e4f1545357fa34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Burnichon?= Date: Mon, 13 Apr 2015 19:49:55 +0200 Subject: [PATCH 7/8] Missing ControllerProvider in Application and error in private method --- lib/Alchemy/Phrasea/Application.php | 4 ++-- .../Phrasea/Controller/Admin/TaskManagerController.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Alchemy/Phrasea/Application.php b/lib/Alchemy/Phrasea/Application.php index 1daa78fea2..ff9577a6bc 100644 --- a/lib/Alchemy/Phrasea/Application.php +++ b/lib/Alchemy/Phrasea/Application.php @@ -312,6 +312,7 @@ class Application extends SilexApplication 'Alchemy\Phrasea\ControllerProvider\Admin\SearchEngine' => [], 'Alchemy\Phrasea\ControllerProvider\Admin\Setup' => [], 'Alchemy\Phrasea\ControllerProvider\Admin\Subdefs' => [], + 'Alchemy\Phrasea\ControllerProvider\Admin\TaskManager' => [], 'Alchemy\Phrasea\ControllerProvider\Admin\Users' => [], 'Alchemy\Phrasea\ControllerProvider\Datafiles' => [], 'Alchemy\Phrasea\ControllerProvider\Lightbox' => [], @@ -622,8 +623,6 @@ class Application extends SilexApplication $this->mount('/login/', new Login()); $this->mount('/developers/', new Developers()); - $this->mount('/admin/task-manager', new TaskManager()); - $this->mount('/client/', new ClientRoot()); $this->mount('/prod/query/', new Query()); @@ -676,6 +675,7 @@ class Application extends SilexApplication '/admin/search-engine' => 'Alchemy\Phrasea\ControllerProvider\Admin\SearchEngine', '/admin/setup' => 'Alchemy\Phrasea\ControllerProvider\Admin\Setup', '/admin/subdefs' => 'Alchemy\Phrasea\ControllerProvider\Admin\Subdefs', + '/admin/task-manager' => 'Alchemy\Phrasea\ControllerProvider\Admin\TaskManager', '/admin/users' => 'Alchemy\Phrasea\ControllerProvider\Admin\Users', '/datafiles' => 'Alchemy\Phrasea\ControllerProvider\Datafiles', '/include/minify' => 'Alchemy\Phrasea\ControllerProvider\Minifier', diff --git a/lib/Alchemy/Phrasea/Controller/Admin/TaskManagerController.php b/lib/Alchemy/Phrasea/Controller/Admin/TaskManagerController.php index 0a3b1b4bf0..bbe065862d 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/TaskManagerController.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/TaskManagerController.php @@ -140,7 +140,7 @@ class TaskManagerController extends Controller if ($request->getRequestFormat() === "json") { foreach ($tasks as $k => $task) { - $tasks[$k]['urls'] = $this->getTaskResourceUrls($this->app, $task['id']); + $tasks[$k]['urls'] = $this->getTaskResourceUrls($task['id']); } return $this->app->json($tasks); @@ -298,7 +298,7 @@ class TaskManagerController extends Controller return $this->app->json(array_replace([ 'id' => $task->getId(), 'name' => $task->getName(), - 'urls' => $this->getTaskResourceUrls($this->app, $task->getId()) + 'urls' => $this->getTaskResourceUrls($task->getId()) ], $this->getLiveInformationRequest()->getTask($task) )); From 21195820f26fcc2fe77d87a936d62a64487f0955 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Burnichon?= Date: Tue, 14 Apr 2015 11:07:26 +0200 Subject: [PATCH 8/8] Fixup form submission. In our case, we want to allow empty requests... If using handleRequest, the form should at least contains the CSRF tokens. --- lib/Alchemy/Phrasea/Controller/Admin/SetupController.php | 9 ++++++--- .../Alchemy/Tests/Phrasea/Controller/Admin/SetupTest.php | 6 ++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/Alchemy/Phrasea/Controller/Admin/SetupController.php b/lib/Alchemy/Phrasea/Controller/Admin/SetupController.php index bab5d26ed1..fad138e012 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/SetupController.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/SetupController.php @@ -22,17 +22,20 @@ class SetupController extends Controller $manipulator = $this->app['registry.manipulator']; $form = $manipulator->createForm($this->app['conf']); + $status = 200; if ('POST' === $request->getMethod()) { - $form->handleRequest($request); + $form->submit($request->request->all()); if ($form->isValid()) { $this->app['conf']->set('registry', $manipulator->getRegistryData($form)); return $this->app->redirectPath('setup_display_globals'); } + + $status = 400; } - return $this->render('admin/setup.html.twig', [ + return $this->renderResponse('admin/setup.html.twig', [ 'form' => $form->createView(), - ]); + ], $status); } } diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Admin/SetupTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Admin/SetupTest.php index 46b469fe21..b1120568f8 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Admin/SetupTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Admin/SetupTest.php @@ -52,7 +52,9 @@ class SetupTest extends \PhraseanetAuthenticatedWebTestCase ->with('registry',$this->isType('array')); self::$DI['app']['conf'] = $registry; - self::$DI['client']->request('POST', '/admin/setup/', ['_token' => 'token']); - $this->assertTrue(self::$DI['client']->getResponse()->isRedirect()); + /** @var Client $client */ + $client = self::$DI['client']; + $client->request('POST', '/admin/setup/', ['_token' => 'token']); + $this->assertTrue($client->getResponse()->isRedirect('/admin/setup/')); } }