Files
Phraseanet/lib/Alchemy/Phrasea/ControllerProvider/Admin/Subdefs.php
2015-04-13 18:25:28 +02:00

61 lines
1.8 KiB
PHP

<?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\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, 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)
{
/** @var ControllerCollection $controllers */
$controllers = $app['controllers_factory'];
/** @var Firewall $firewall */
$firewall = $app['firewall'];
$firewall->addMandatoryAuthentication($controllers);
$controllers->before(function (Request $request) use ($firewall) {
$firewall->requireAccessToModule('admin')
->requireRightOnSbas($request->attributes->get('sbas_id'), 'bas_modify_struct');
});
$controllers->get('/{sbas_id}/', 'controller.admin.subdefs:indexAction')
->bind('admin_subdefs_subdef')
->assert('sbas_id', '\d+');
$controllers->post('/{sbas_id}/', 'controller.admin.subdefs:changeSubdefsAction')
->bind('admin_subdefs_subdef_update')
->assert('sbas_id', '\d+');
return $controllers;
}
}