Skip to content

Commit

Permalink
Fix creating proxies when adding notification to proxy class
Browse files Browse the repository at this point in the history
  • Loading branch information
Gilet Maximilien committed Oct 18, 2017
1 parent ac41b38 commit bce7c2d
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions Manager/NotificationManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Mgilet\NotificationBundle\Manager;

use Doctrine\Common\Util\ClassUtils;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityNotFoundException;
use Mgilet\NotificationBundle\Entity\NotifiableEntity;
Expand Down Expand Up @@ -157,7 +158,7 @@ public function generateIdentifier(NotifiableInterface $notifiable)
public function getNotifiableEntity(NotifiableInterface $notifiable)
{
$identifier = $this->generateIdentifier($notifiable);
$class = get_class($notifiable);
$class = ClassUtils::getRealClass(get_class($notifiable));
$entity = $this->notifiableRepository->findOneBy(array(
'identifier' => $identifier,
'class' => $class
Expand Down Expand Up @@ -252,7 +253,10 @@ public function getAll()
*/
public function getNotifications(NotifiableInterface $notifiable)
{
return $this->notificationRepository->findAllByNotifiable($this->generateIdentifier($notifiable), get_class($notifiable));
return $this->notificationRepository->findAllByNotifiable(
$this->generateIdentifier($notifiable),
ClassUtils::getRealClass(get_class($notifiable))
);
}

/**
Expand All @@ -264,7 +268,10 @@ public function getNotifications(NotifiableInterface $notifiable)
*/
public function getUnseenNotifications(NotifiableInterface $notifiable)
{
return $this->notificationRepository->findAllByNotifiable($this->generateIdentifier($notifiable), get_class($notifiable), false);
return $this->notificationRepository->findAllByNotifiable(
$this->generateIdentifier($notifiable),
ClassUtils::getRealClass(get_class($notifiable)),
false);
}

/**
Expand All @@ -276,7 +283,10 @@ public function getUnseenNotifications(NotifiableInterface $notifiable)
*/
public function getSeenNotifications(NotifiableInterface $notifiable)
{
return $this->notificationRepository->findAllByNotifiable($this->generateIdentifier($notifiable), get_class($notifiable), true);
return $this->notificationRepository->findAllByNotifiable(
$this->generateIdentifier($notifiable),
ClassUtils::getRealClass(get_class($notifiable)),
true);
}


Expand Down Expand Up @@ -448,7 +458,7 @@ public function markAllAsSeen(NotifiableInterface $notifiable, $flush = false)
{
$nns = $this->notifiableNotificationRepository->findAllForNotifiable(
$this->generateIdentifier($notifiable),
get_class($notifiable)
ClassUtils::getRealClass(get_class($notifiable))
);
foreach ($nns as $nn) {
$nn->setSeen(true);
Expand Down Expand Up @@ -491,7 +501,7 @@ public function getNotificationCount(NotifiableInterface $notifiable)
{
return $this->notifiableNotificationRepository->getNotificationCount(
$this->generateIdentifier($notifiable),
get_class($notifiable)
ClassUtils::getRealClass(get_class($notifiable))
);
}

Expand All @@ -508,7 +518,7 @@ public function getUnseenNotificationCount(NotifiableInterface $notifiable)
{
return $this->notifiableNotificationRepository->getNotificationCount(
$this->generateIdentifier($notifiable),
get_class($notifiable),
ClassUtils::getRealClass(get_class($notifiable)),
false
);
}
Expand All @@ -526,7 +536,7 @@ public function getSeenNotificationCount(NotifiableInterface $notifiable)
{
return $this->notifiableNotificationRepository->getNotificationCount(
$this->generateIdentifier($notifiable),
get_class($notifiable),
ClassUtils::getRealClass(get_class($notifiable)),
true
);
}
Expand Down

0 comments on commit bce7c2d

Please sign in to comment.