mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 15:13:50 +00:00
Adding some features to load for notifications)
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\MainBundle\DataFixtures\ORM;
|
||||
|
||||
use Doctrine\Common\DataFixtures\AbstractFixture;
|
||||
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use Symfony\Component\Intl\Intl;
|
||||
use Chill\MainBundle\Entity\Notification;
|
||||
|
||||
/**
|
||||
* Load notififications into database
|
||||
*/
|
||||
trait LoadAbstractNotificationsTrait
|
||||
{
|
||||
public function load(ObjectManager $manager)
|
||||
{
|
||||
foreach ($this->notifs as $notif) {
|
||||
$entityId = $this->getReference($notif['entityRef'])->getId();
|
||||
|
||||
print('Adding notification for '.$notif['entityClass'].'(entity id:'.$entityId.")\n");
|
||||
|
||||
$newNotif = (new Notification())
|
||||
->setMessage($notif['message'])
|
||||
->setSender($this->getReference($notif['sender']))
|
||||
->setRelatedEntityClass($notif['entityClass'])
|
||||
->setRelatedEntityId($entityId)
|
||||
->setDate(new \DateTimeImmutable('now'))
|
||||
->setRead([])
|
||||
;
|
||||
|
||||
foreach ($notif['addressees'] as $addressee) {
|
||||
$newNotif->addAddressee($this->getReference($addressee));
|
||||
}
|
||||
|
||||
$manager->persist($newNotif);
|
||||
|
||||
$manager->flush();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user