mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-17 15:03:25 +00:00
Add LazyLocator
This commit is contained in:
@@ -13,10 +13,12 @@ namespace Alchemy\Phrasea\ControllerProvider\Admin;
|
||||
|
||||
use Alchemy\Phrasea\Application as PhraseaApplication;
|
||||
use Alchemy\Phrasea\Controller\Admin\CollectionController;
|
||||
use Alchemy\Phrasea\Controller\LazyLocator;
|
||||
use Alchemy\Phrasea\ControllerProvider\ControllerProviderTrait;
|
||||
use Silex\Application;
|
||||
use Silex\ControllerProviderInterface;
|
||||
use Silex\ServiceProviderInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
class Collection implements ControllerProviderInterface, ServiceProviderInterface
|
||||
{
|
||||
@@ -26,9 +28,7 @@ class Collection implements ControllerProviderInterface, ServiceProviderInterfac
|
||||
{
|
||||
$app['controller.admin.collection'] = $app->share(function (PhraseaApplication $app) {
|
||||
return (new CollectionController($app))
|
||||
->setUserQueryFactory(function () use ($app) {
|
||||
return $app['phraseanet.user-query'];
|
||||
})
|
||||
->setUserQueryFactory(new LazyLocator($app, 'phraseanet.user-query'))
|
||||
;
|
||||
});
|
||||
}
|
||||
@@ -40,10 +40,12 @@ class Collection implements ControllerProviderInterface, ServiceProviderInterfac
|
||||
public function connect(Application $app)
|
||||
{
|
||||
$controllers = $this->createAuthenticatedCollection($app);
|
||||
$firewall = $this->getFirewall($app);
|
||||
|
||||
$controllers->before(function () use ($app) {
|
||||
$app['firewall']->requireAccessToModule('admin')
|
||||
->requireRightOnBase($app['request']->attributes->get('bas_id'), 'canadmin');
|
||||
$controllers->before(function (Request $request) use ($firewall) {
|
||||
$firewall
|
||||
->requireAccessToModule('admin')
|
||||
->requireRightOnBase($request->attributes->get('bas_id'), 'canadmin');
|
||||
});
|
||||
|
||||
$controllers->get('/{bas_id}/', 'controller.admin.collection:getCollection')
|
||||
|
@@ -46,9 +46,10 @@ class ConnectedUsers implements ControllerProviderInterface, ServiceProviderInte
|
||||
public function connect(Application $app)
|
||||
{
|
||||
$controllers = $this->createAuthenticatedCollection($app);
|
||||
$firewall = $this->getFirewall($app);
|
||||
|
||||
$controllers->before(function () use ($app) {
|
||||
$app['firewall']->requireAccessToModule('Admin');
|
||||
$controllers->before(function () use ($firewall) {
|
||||
$firewall->requireAccessToModule('Admin');
|
||||
});
|
||||
|
||||
$controllers->get('/', 'controller.admin.connected-users:listConnectedUsers')
|
||||
|
@@ -13,6 +13,8 @@ namespace Alchemy\Phrasea\ControllerProvider\Admin;
|
||||
|
||||
use Alchemy\Phrasea\Application as PhraseaApplication;
|
||||
use Alchemy\Phrasea\Controller\Admin\DashboardController;
|
||||
use Alchemy\Phrasea\Controller\LazyLocator;
|
||||
use Alchemy\Phrasea\ControllerProvider\ControllerProviderTrait;
|
||||
use Silex\Application;
|
||||
use Silex\ControllerCollection;
|
||||
use Silex\ControllerProviderInterface;
|
||||
@@ -20,13 +22,14 @@ use Silex\ServiceProviderInterface;
|
||||
|
||||
class Dashboard implements ControllerProviderInterface, ServiceProviderInterface
|
||||
{
|
||||
use ControllerProviderTrait;
|
||||
|
||||
public function register(Application $app)
|
||||
{
|
||||
$app['controller.admin.dashboard'] = $app->share(function (PhraseaApplication $app) {
|
||||
return (new DashboardController($app))
|
||||
->setDelivererLocator(function () use ($app) {
|
||||
return $app['notification.deliverer'];
|
||||
});
|
||||
->setDelivererLocator(new LazyLocator($app, 'notification.deliverer'))
|
||||
;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -36,11 +39,11 @@ class Dashboard implements ControllerProviderInterface, ServiceProviderInterface
|
||||
|
||||
public function connect(Application $app)
|
||||
{
|
||||
/** @var ControllerCollection $controllers */
|
||||
$controllers = $app['controllers_factory'];
|
||||
$controllers = $this->createCollection($app);
|
||||
$firewall = $this->getFirewall($app);
|
||||
|
||||
$controllers->before(function () use ($app) {
|
||||
$app['firewall']->requireAdmin();
|
||||
$controllers->before(function () use ($firewall) {
|
||||
$firewall->requireAdmin();
|
||||
});
|
||||
|
||||
$controllers->get('/', 'controller.admin.dashboard:slash')
|
||||
|
@@ -13,6 +13,7 @@ namespace Alchemy\Phrasea\ControllerProvider\Admin;
|
||||
|
||||
use Alchemy\Phrasea\Application as PhraseaApplication;
|
||||
use Alchemy\Phrasea\Controller\Admin\DataboxController;
|
||||
use Alchemy\Phrasea\Controller\LazyLocator;
|
||||
use Alchemy\Phrasea\ControllerProvider\ControllerProviderTrait;
|
||||
use Alchemy\Phrasea\Security\Firewall;
|
||||
use Silex\Application;
|
||||
@@ -28,9 +29,7 @@ class Databox implements ControllerProviderInterface, ServiceProviderInterface
|
||||
{
|
||||
$app['controller.admin.databox'] = $app->share(function (PhraseaApplication $app) {
|
||||
return (new DataboxController($app))
|
||||
->setUserQueryFactory(function () use ($app) {
|
||||
return $app['phraseanet.user-query'];
|
||||
})
|
||||
->setUserQueryFactory(new LazyLocator($app, 'phraseanet.user-query'))
|
||||
;
|
||||
});
|
||||
}
|
||||
|
@@ -12,6 +12,7 @@
|
||||
namespace Alchemy\Phrasea\ControllerProvider\Admin;
|
||||
|
||||
use Alchemy\Phrasea\Controller\Admin\UserController;
|
||||
use Alchemy\Phrasea\Controller\LazyLocator;
|
||||
use Alchemy\Phrasea\ControllerProvider\ControllerProviderTrait;
|
||||
use Silex\Application;
|
||||
use Silex\ControllerProviderInterface;
|
||||
@@ -25,12 +26,8 @@ class Users implements ControllerProviderInterface, ServiceProviderInterface
|
||||
{
|
||||
$app['controller.admin.users'] = $app->share(function () use ($app) {
|
||||
return (new UserController($app))
|
||||
->setDelivererLocator(function () use ($app) {
|
||||
return $app['notification.deliverer'];
|
||||
})
|
||||
->setUserQueryFactory(function () use ($app) {
|
||||
return $app['phraseanet.user-query'];
|
||||
})
|
||||
->setDelivererLocator(new LazyLocator($app, 'notification.deliverer'))
|
||||
->setUserQueryFactory(new LazyLocator($app, 'phraseanet.user-query'))
|
||||
;
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user