diff options
author | Frédéric Guillot <fred@kanboard.net> | 2014-12-27 21:11:11 -0500 |
---|---|---|
committer | Frédéric Guillot <fred@kanboard.net> | 2014-12-27 21:11:11 -0500 |
commit | 88d84073aecbe8bdc5f10825b6d7ca6b81c5f7b1 (patch) | |
tree | e823c8e13e9ffba115c8e1f5a05a514cac5322df /app/Subscriber | |
parent | 0a14c8d5e5538e487dd6b012771f72aea6f4d5a6 (diff) |
Add more subscribers
Diffstat (limited to 'app/Subscriber')
-rw-r--r-- | app/Subscriber/AuthSubscriber.php | 27 | ||||
-rw-r--r-- | app/Subscriber/BootstrapSubscriber.php | 22 |
2 files changed, 49 insertions, 0 deletions
diff --git a/app/Subscriber/AuthSubscriber.php b/app/Subscriber/AuthSubscriber.php new file mode 100644 index 00000000..161a7afd --- /dev/null +++ b/app/Subscriber/AuthSubscriber.php @@ -0,0 +1,27 @@ +<?php + +namespace Subscriber; + +use Core\Request; +use Event\AuthEvent; +use Symfony\Component\EventDispatcher\EventSubscriberInterface; + +class AuthSubscriber extends Base implements EventSubscriberInterface +{ + public static function getSubscribedEvents() + { + return array( + 'auth.success' => array('onSuccess', 0), + ); + } + + public function onSuccess(AuthEvent $event) + { + $this->lastLogin->create( + $event->getAuthType(), + $event->getUserId(), + Request::getIpAddress(), + Request::getUserAgent() + ); + } +} diff --git a/app/Subscriber/BootstrapSubscriber.php b/app/Subscriber/BootstrapSubscriber.php new file mode 100644 index 00000000..30b8f168 --- /dev/null +++ b/app/Subscriber/BootstrapSubscriber.php @@ -0,0 +1,22 @@ +<?php + +namespace Subscriber; + +use Symfony\Component\EventDispatcher\EventSubscriberInterface; + +class BootstrapSubscriber extends Base implements EventSubscriberInterface +{ + public static function getSubscribedEvents() + { + return array( + 'session.bootstrap' => array('setup', 0), + 'api.bootstrap' => array('setup', 0), + ); + } + + public function setup() + { + $this->container['config']->setupTranslations(); + $this->container['config']->setupTimezone(); + } +} |