Use NotifierAware in some controllers

This commit is contained in:
Benoît Burnichon
2015-05-12 19:17:10 +02:00
parent 88cb63b3ed
commit 4eabe26e58
4 changed files with 16 additions and 11 deletions

View File

@@ -10,7 +10,7 @@
namespace Alchemy\Phrasea\Controller\Admin; namespace Alchemy\Phrasea\Controller\Admin;
use Alchemy\Phrasea\Application; use Alchemy\Phrasea\Application\Helper\NotifierAware;
use Alchemy\Phrasea\Authentication\Authenticator; use Alchemy\Phrasea\Authentication\Authenticator;
use Alchemy\Phrasea\Cache\Cache; use Alchemy\Phrasea\Cache\Cache;
use Alchemy\Phrasea\Controller\Controller; use Alchemy\Phrasea\Controller\Controller;
@@ -19,7 +19,6 @@ use Alchemy\Phrasea\Exception\RuntimeException;
use Alchemy\Phrasea\Model\Manipulator\ACLManipulator; use Alchemy\Phrasea\Model\Manipulator\ACLManipulator;
use Alchemy\Phrasea\Model\Manipulator\UserManipulator; use Alchemy\Phrasea\Model\Manipulator\UserManipulator;
use Alchemy\Phrasea\Model\Repositories\UserRepository; use Alchemy\Phrasea\Model\Repositories\UserRepository;
use Alchemy\Phrasea\Notification\Deliverer;
use Alchemy\Phrasea\Notification\Mail\MailTest; use Alchemy\Phrasea\Notification\Mail\MailTest;
use Alchemy\Phrasea\Notification\Receiver; use Alchemy\Phrasea\Notification\Receiver;
use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\RedirectResponse;
@@ -27,6 +26,8 @@ use Symfony\Component\HttpFoundation\Request;
class DashboardController extends Controller class DashboardController extends Controller
{ {
use NotifierAware;
/** /**
* Display admin dashboard page * Display admin dashboard page
* *
@@ -89,9 +90,7 @@ class DashboardController extends Controller
$mail = MailTest::create($this->app, $receiver); $mail = MailTest::create($this->app, $receiver);
/** @var Deliverer $deliverer */ $this->deliver($mail);
$deliverer = $this->app['notification.deliverer'];
$deliverer->deliver($mail);
/** @var \Swift_SpoolTransport $spoolTransport */ /** @var \Swift_SpoolTransport $spoolTransport */
$spoolTransport = $this->app['swiftmailer.spooltransport']; $spoolTransport = $this->app['swiftmailer.spooltransport'];

View File

@@ -10,6 +10,7 @@
namespace Alchemy\Phrasea\Controller\Admin; namespace Alchemy\Phrasea\Controller\Admin;
use Alchemy\Phrasea\Application\Helper\NotifierAware;
use Alchemy\Phrasea\Controller\Controller; use Alchemy\Phrasea\Controller\Controller;
use Alchemy\Phrasea\Core\Response\CSVFileResponse; use Alchemy\Phrasea\Core\Response\CSVFileResponse;
use Alchemy\Phrasea\Helper\User as UserHelper; use Alchemy\Phrasea\Helper\User as UserHelper;
@@ -20,7 +21,6 @@ use Alchemy\Phrasea\Model\Manipulator\UserManipulator;
use Alchemy\Phrasea\Model\NativeQueryProvider; use Alchemy\Phrasea\Model\NativeQueryProvider;
use Alchemy\Phrasea\Model\Repositories\RegistrationRepository; use Alchemy\Phrasea\Model\Repositories\RegistrationRepository;
use Alchemy\Phrasea\Model\Repositories\UserRepository; use Alchemy\Phrasea\Model\Repositories\UserRepository;
use Alchemy\Phrasea\Notification\Deliverer;
use Alchemy\Phrasea\Notification\Mail\MailSuccessEmailUpdate; use Alchemy\Phrasea\Notification\Mail\MailSuccessEmailUpdate;
use Alchemy\Phrasea\Notification\Receiver; use Alchemy\Phrasea\Notification\Receiver;
use Goodby\CSV\Export\Protocol\ExporterInterface; use Goodby\CSV\Export\Protocol\ExporterInterface;
@@ -30,6 +30,8 @@ use Symfony\Component\HttpFoundation\Response;
class UserController extends Controller class UserController extends Controller
{ {
use NotifierAware;
public function editRightsAction(Request $request) public function editRightsAction(Request $request)
{ {
$rights = $this->getUserEditHelper($request); $rights = $this->getUserEditHelper($request);
@@ -507,9 +509,7 @@ class UserController extends Controller
$receiver = new Receiver(null, $user->getEmail()); $receiver = new Receiver(null, $user->getEmail());
$mail = MailSuccessEmailUpdate::create($this->app, $receiver, null, $message); $mail = MailSuccessEmailUpdate::create($this->app, $receiver, null, $message);
/** @var Deliverer $deliverer */ $this->deliver($mail);
$deliverer = $this->app['notification.deliverer'];
$deliverer->deliver($mail);
} }
} }
} }

View File

@@ -23,7 +23,10 @@ class Dashboard implements ControllerProviderInterface, ServiceProviderInterface
public function register(Application $app) public function register(Application $app)
{ {
$app['controller.admin.dashboard'] = $app->share(function (PhraseaApplication $app) { $app['controller.admin.dashboard'] = $app->share(function (PhraseaApplication $app) {
return new DashboardController($app); return (new DashboardController($app))
->setDelivererLocator(function () use ($app) {
return $app['notification.deliverer'];
});
}); });
} }

View File

@@ -24,7 +24,10 @@ class Users implements ControllerProviderInterface, ServiceProviderInterface
public function register(Application $app) public function register(Application $app)
{ {
$app['controller.admin.users'] = $app->share(function () use ($app) { $app['controller.admin.users'] = $app->share(function () use ($app) {
return new UserController($app); return (new UserController($app))
->setDelivererLocator(function () use ($app) {
return $app['notification.deliverer'];
});
}); });
} }