Skip to content

Commit

Permalink
Merge pull request #2 from ngodfraind/master
Browse files Browse the repository at this point in the history
Configurable entity manager + usable in command line.
  • Loading branch information
maxailloud committed Feb 6, 2014
2 parents 42e9215 + 9b0b2e0 commit ee098ad
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
5 changes: 5 additions & 0 deletions Resources/config/services/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,8 @@ services:
arguments: [@translator]
tags:
- { name: twig.extension }

icap.notification.orm.entity_manager:
alias: doctrine.orm.entity_manager


19 changes: 13 additions & 6 deletions Service/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ protected function getFollowerResourceRepository()
public function __construct(Container $container)
{
$this->container = $container;
$this->em = $container->get('doctrine.orm.entity_manager');
$this->em = $container->get('icap.notification.orm.entity_manager');
$this->security = $container->get('security.context');
}

Expand Down Expand Up @@ -175,17 +175,24 @@ public function notifyUsers(Notification $notification, NotifiableInterface $not

$userIds = array_unique($userIds);
$excludeUserIds = $notifiable->getExcludeUserIds();
$removeUserIds = array();

if (!empty($excludeUserIds)) {
$userIds = array_diff($userIds, $excludeUserIds);
}

//Remove doer from user list as long as the logged user
$loggedUser = $this->security->getToken()->getUser();
$removeUserIds = array($notification->getUserId());
if (!empty($loggedUser) && $loggedUser->getId() != $notification->getUserId()) {
array_push($removeUserIds, $loggedUser->getId());
$token = $this->security->getToken();

if ($token) {
//Remove doer from user list as long as the logged user
$loggedUser = $token->getUser();
$removeUserIds = array($notification->getUserId());

if (!empty($loggedUser) && $loggedUser->getId() != $notification->getUserId()) {
array_push($removeUserIds, $loggedUser->getId());
}
}

$userIds = array_diff($userIds, $removeUserIds);

if (count($userIds)>0) {
Expand Down

0 comments on commit ee098ad

Please sign in to comment.