コード例 #1
0
 /** @ORM\PostUpdate */
 public function postUpdate(Notification $notification, LifecycleEventArgs $event)
 {
     $entityManager = $event->getEntityManager();
     if ($notification->getType() == 1) {
         $cacheDriver = $entityManager->getConfiguration()->getResultCacheImpl();
         $cacheDriver->delete('getUnreadPrestationNotifications_' . $notification->getReceiver()->getId() . '_' . $notification->getPrestation()->getId());
         $cacheDriver->delete('getUnreadPrestationsNotifications_' . $notification->getReceiver()->getId());
     }
 }
コード例 #2
0
 public function createPrestationNotification(Prestation $prestation)
 {
     $status = $prestation->getStatus()->getId();
     $photographer = $prestation->getDevis()->getCompany()->getPhotographer();
     $client = $prestation->getClient();
     switch ($status) {
         case 1:
             $to = $photographer;
             $subject = self::PRESTATION_CREEE;
             break;
         case 2:
             //PHOTOGRAPHER_OK
             $to = $client;
             $subject = self::PHOTOGRAPHER_OK;
             break;
         case 3:
             //Cancel-photographer
             $to = $client;
             $subject = self::PHOTOGRAPHER_KO;
             break;
         case 4:
             //Cancel-Client
             $to = $photographer;
             $subject = self::CLIENT_KO;
             break;
         case 5:
             //Valide
             $to = $photographer;
             $subject = self::PRESTATION_OK;
             break;
         case 6:
             $to = $photographer;
             $subject = self::OLD_PRESTATION;
             break;
         case 7:
             $to = $photographer;
             $subject = self::PHOTOS_DELIVERED;
             break;
         case 8:
             $to = $photographer;
             $subject = self::CLOSED_PRESTATION;
             break;
         case 9:
             $to = $client;
             $subject = self::CANCELED_PHOTOGRAPHER;
             break;
         case 10:
             $to = $photographer;
             $subject = self::CANCELED_CLIENT;
             break;
         case 11:
             $to = $photographer;
             $subject = self::LITIGE_CLIENT;
             break;
         case 12:
             $to = $client;
             $subject = self::LITIGE_PHOTOGRAPHER;
             break;
     }
     $notification = new Notification();
     $notification->setType(1);
     $notification->setPrestation($prestation);
     $notification->setContent($subject);
     $notification->setReceiver($to);
     try {
         $this->em->persist($notification);
         $this->em->flush();
     } catch (\Exception $e) {
         $this->session->errorFlashMessage();
         $this->logger->error($e->getMessage());
     }
 }