Skip to content

Commit

Permalink
bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
behram committed May 22, 2015
1 parent 52c25fb commit d3a6c29
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 27 deletions.
8 changes: 4 additions & 4 deletions app/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,12 @@ services:
- { name: h4cc_alice_fixtures.provider }
user.event_subscriber:
class: Ojs\UserBundle\Listeners\UserSubscriber
arguments: [ @mailer, @twig, @doctrine.orm.entity_manager, @request, "%system_email%" ]
arguments: [ @mailer, @twig, @doctrine.orm.entity_manager, @request_stack, "%system_email%" ]
tags:
- { name: kernel.event_subscriber }
user.event_listener:
class: Ojs\UserBundle\Listeners\UserListener
arguments: [@request]
arguments: [@request_stack]
tags:
- { name: doctrine.event_listener, event: postPersist }
user.helper:
Expand All @@ -129,13 +129,13 @@ services:
- { name: kernel.event_listener, event: kernel.request, method: onKernelRequest }
proxy.event_listener:
class: Ojs\UserBundle\Listeners\ProxyListener
arguments: [@request]
arguments: [@request_stack]
tags:
- { name: doctrine.event_listener, event: postPersist }
- { name: doctrine.event_listener, event: preRemove }
article.event_listener:
class: Ojs\UserBundle\Listeners\ArticleListener
arguments: [@security.token_storage, @request]
arguments: [@security.token_storage, @request_stack]
tags:
- { name: doctrine.event_listener, event: postPersist }
- { name: doctrine.event_listener, event: preRemove }
12 changes: 6 additions & 6 deletions src/Ojs/UserBundle/Listeners/ArticleListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@
use Ojs\UserBundle\Entity\EventLog;
use Ojs\UserBundle\Entity\User;
use Ojs\Common\Params\ArticleEventLogParams;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;

class ArticleListener
{
/** @var TokenStorage */
protected $tokenStorage;
/** @var Request */
/** @var RequestStack */
protected $request;

/**
* @param TokenStorage $tokenStorage
* @param Request $request
* @param RequestStack $request
*/
public function __construct(TokenStorage $tokenStorage, Request $request)
public function __construct(TokenStorage $tokenStorage, RequestStack $request)
{
$this->tokenStorage = $tokenStorage;
$this->request = $request;
Expand Down Expand Up @@ -56,7 +56,7 @@ public function postPersist(LifecycleEventArgs $args)
$event = new EventLog();
$event->setUserId($user->getId());
$event->setEventInfo(ArticleEventLogParams::$ARTICLE_SUBMISSION);
$event->setIp($this->request->getClientIp());
$event->setIp($this->request->getCurrentRequest()->getClientIp());
$entityManager->persist($event);

$entityManager->flush();
Expand Down Expand Up @@ -87,7 +87,7 @@ public function preRemove(LifecycleEventArgs $args)
//log as eventlog
$event = new EventLog();
$event->setEventInfo(ArticleEventLogParams::$ARTICLE_REMOVE);
$event->setIp($this->request->getClientIp());
$event->setIp($this->request->getCurrentRequest()->getClientIp());
$event->setUserId($user->getId());
$event->setAffectedUserId($entity->getSubmitterId());
$entityManager->persist($event);
Expand Down
12 changes: 6 additions & 6 deletions src/Ojs/UserBundle/Listeners/ProxyListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
use Ojs\UserBundle\Entity\EventLog;
use Ojs\UserBundle\Entity\Proxy;
use Ojs\Common\Params\ProxyEventLogParams;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Response;

class ProxyListener
{
/** @var Request */
/** @var RequestStack */
protected $request;

/**
* @param Request $request
* @param RequestStack $request
*/
public function __construct(Request $request = null)
public function __construct(RequestStack $request = null)
{
$this->request = $request;
}
Expand Down Expand Up @@ -44,7 +44,7 @@ public function postPersist(LifecycleEventArgs $args)
$event->setUserId($entity->getClientUser()->getId());
$event->setEventInfo(ProxyEventLogParams::$PROXY_CREATE);
$event->setAffectedUserId($entity->getProxyUser()->getId());
$event->setIp($this->request->getClientIp());
$event->setIp($this->request->getCurrentRequest()->getClientIp());
$entityManager->persist($event);

$entityManager->flush();
Expand Down Expand Up @@ -72,7 +72,7 @@ public function preRemove(LifecycleEventArgs $args)
//log as eventlog
$event = new EventLog();
$event->setEventInfo(ProxyEventLogParams::$PROXY_DROP);
$event->setIp($this->request->getClientIp());
$event->setIp($this->request->getCurrentRequest()->getClientIp());
$event->setAffectedUserId($entity->getProxyUserId());
$event->setUserId($entity->getClientUserId());
$entityManager->persist($event);
Expand Down
12 changes: 6 additions & 6 deletions src/Ojs/UserBundle/Listeners/UserListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,25 @@
use Ojs\UserBundle\Entity\EventLog;
use Ojs\UserBundle\Entity\User;
use Ojs\Common\Params\UserEventLogParams;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Response;

class UserListener
{
/** @var Request */
/** @var RequestStack */
protected $request;

/**
* @param Request $request
* @param RequestStack $request
*/
public function __construct(Request $request)
public function __construct(RequestStack $request)
{
$this->request = $request;
}

/**
* Every new user log to event log
* @param LifecycleEventArgs|Request $args
* @param LifecycleEventArgs|RequestStack $args
* @link http://docs.doctrine-project.org/en/latest/reference/events.html#postupdate-postremove-postpersist
* @return Response never null
*/
Expand All @@ -39,7 +39,7 @@ public function postPersist(LifecycleEventArgs $args)
//log as eventlog
$event = new EventLog();
$event->setEventInfo(UserEventLogParams::$USER_ADD);
$event->setIp($this->request->getClientIp());
$event->setIp($this->request->getCurrentRequest()->getClientIp());
$event->setUserId($entity->getId());
$entityManager->persist($event);

Expand Down
10 changes: 5 additions & 5 deletions src/Ojs/UserBundle/Listeners/UserSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use Ojs\UserBundle\Event\UserEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Ojs\Common\Params\UserEventLogParams;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;

class UserSubscriber implements EventSubscriberInterface
{
Expand All @@ -22,7 +22,7 @@ class UserSubscriber implements EventSubscriberInterface
protected $twig;
/** @var EntityManager */
protected $em;
/** @var Request */
/** @var RequestStack */
protected $request;
/** @var string */
protected $systemEmail;
Expand All @@ -31,10 +31,10 @@ class UserSubscriber implements EventSubscriberInterface
* @param \Swift_Mailer $mailer
* @param \Twig_Environment $twig
* @param EntityManager $em
* @param Request $request
* @param RequestStack $request
* @param $systemEmail
*/
public function __construct(\Swift_Mailer $mailer, \Twig_Environment $twig, EntityManager $em, Request $request, $systemEmail)
public function __construct(\Swift_Mailer $mailer, \Twig_Environment $twig, EntityManager $em, RequestStack $request, $systemEmail)
{
$this->mailer = $mailer;
$this->twig = $twig;
Expand Down Expand Up @@ -80,7 +80,7 @@ public function onPasswordChange(UserEvent $event)
//log as eventlog
$eventLog = new EventLog();
$eventLog->setEventInfo(UserEventLogParams::$PASSWORD_CHANGE);
$eventLog->setIp($this->request->getClientIp());
$eventLog->setIp($this->request->getCurrentRequest()->getClientIp());
$eventLog->setUserId($event->getUser()->getId());
$this->em->persist($eventLog);

Expand Down

0 comments on commit d3a6c29

Please sign in to comment.