mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-11 03:53:13 +00:00
Refactor Admin/SetupController
This commit is contained in:
@@ -312,6 +312,7 @@ class Application extends SilexApplication
|
|||||||
'Alchemy\Phrasea\ControllerProvider\Admin\Fields' => [],
|
'Alchemy\Phrasea\ControllerProvider\Admin\Fields' => [],
|
||||||
'Alchemy\Phrasea\ControllerProvider\Admin\Root' => [],
|
'Alchemy\Phrasea\ControllerProvider\Admin\Root' => [],
|
||||||
'Alchemy\Phrasea\ControllerProvider\Admin\SearchEngine' => [],
|
'Alchemy\Phrasea\ControllerProvider\Admin\SearchEngine' => [],
|
||||||
|
'Alchemy\Phrasea\ControllerProvider\Admin\Setup' => [],
|
||||||
'Alchemy\Phrasea\ControllerProvider\Admin\Users' => [],
|
'Alchemy\Phrasea\ControllerProvider\Admin\Users' => [],
|
||||||
'Alchemy\Phrasea\ControllerProvider\Datafiles' => [],
|
'Alchemy\Phrasea\ControllerProvider\Datafiles' => [],
|
||||||
'Alchemy\Phrasea\ControllerProvider\Lightbox' => [],
|
'Alchemy\Phrasea\ControllerProvider\Lightbox' => [],
|
||||||
@@ -622,7 +623,6 @@ class Application extends SilexApplication
|
|||||||
$this->mount('/login/', new Login());
|
$this->mount('/login/', new Login());
|
||||||
$this->mount('/developers/', new Developers());
|
$this->mount('/developers/', new Developers());
|
||||||
|
|
||||||
$this->mount('/admin/setup', new Setup());
|
|
||||||
$this->mount('/admin/task-manager', new TaskManager());
|
$this->mount('/admin/task-manager', new TaskManager());
|
||||||
$this->mount('/admin/subdefs', new Subdefs());
|
$this->mount('/admin/subdefs', new Subdefs());
|
||||||
|
|
||||||
@@ -676,6 +676,7 @@ class Application extends SilexApplication
|
|||||||
'/admin/fields' => 'Alchemy\Phrasea\ControllerProvider\Admin\Fields',
|
'/admin/fields' => 'Alchemy\Phrasea\ControllerProvider\Admin\Fields',
|
||||||
'/admin/publications' => 'Alchemy\Phrasea\ControllerProvider\Admin\Feeds',
|
'/admin/publications' => 'Alchemy\Phrasea\ControllerProvider\Admin\Feeds',
|
||||||
'/admin/search-engine' => 'Alchemy\Phrasea\ControllerProvider\Admin\SearchEngine',
|
'/admin/search-engine' => 'Alchemy\Phrasea\ControllerProvider\Admin\SearchEngine',
|
||||||
|
'/admin/setup' => 'Alchemy\Phrasea\ControllerProvider\Admin\Setup',
|
||||||
'/admin/users' => 'Alchemy\Phrasea\ControllerProvider\Admin\Users',
|
'/admin/users' => 'Alchemy\Phrasea\ControllerProvider\Admin\Users',
|
||||||
'/datafiles' => 'Alchemy\Phrasea\ControllerProvider\Datafiles',
|
'/datafiles' => 'Alchemy\Phrasea\ControllerProvider\Datafiles',
|
||||||
'/include/minify' => 'Alchemy\Phrasea\ControllerProvider\Minifier',
|
'/include/minify' => 'Alchemy\Phrasea\ControllerProvider\Minifier',
|
||||||
|
38
lib/Alchemy/Phrasea/Controller/Admin/SetupController.php
Normal file
38
lib/Alchemy/Phrasea/Controller/Admin/SetupController.php
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2015 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Alchemy\Phrasea\Controller\Admin;
|
||||||
|
|
||||||
|
use Alchemy\Phrasea\Controller\Controller;
|
||||||
|
use Alchemy\Phrasea\Core\Configuration\RegistryManipulator;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
|
class SetupController extends Controller
|
||||||
|
{
|
||||||
|
public function submitGlobalsAction(Request $request)
|
||||||
|
{
|
||||||
|
/** @var RegistryManipulator $manipulator */
|
||||||
|
$manipulator = $this->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(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
@@ -11,45 +11,42 @@
|
|||||||
|
|
||||||
namespace Alchemy\Phrasea\ControllerProvider\Admin;
|
namespace Alchemy\Phrasea\ControllerProvider\Admin;
|
||||||
|
|
||||||
use Alchemy\Phrasea\Application;
|
use Alchemy\Phrasea\Application as PhraseaApplication;
|
||||||
use Silex\Application as SilexApplication;
|
use Alchemy\Phrasea\Controller\Admin\SetupController;
|
||||||
|
use Alchemy\Phrasea\Security\Firewall;
|
||||||
|
use Silex\Application;
|
||||||
|
use Silex\ControllerCollection;
|
||||||
use Silex\ControllerProviderInterface;
|
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 = $app['controllers_factory'];
|
||||||
|
|
||||||
$controllers->before(function (Request $request) use ($app) {
|
/** @var Firewall $firewall */
|
||||||
$app['firewall']->requireAdmin();
|
$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')
|
->bind('setup_display_globals')
|
||||||
->method('GET|POST');
|
->method('GET|POST');
|
||||||
|
|
||||||
return $controllers;
|
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(),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user