/**
  * {@inheritdoc}
  */
 public function push(Reminder $reminder)
 {
     $recipientId = $reminder->getRecipient()->getId();
     if (!isset($this->remindersByRecipient[$recipientId])) {
         $this->remindersByRecipient[$recipientId] = array();
     }
     $this->remindersByRecipient[$recipientId][] = $reminder;
 }
Example #2
0
 public function testSetFailureException()
 {
     $expectedMessage = 'Expected message';
     $expectedCode = 100;
     $exception = new \Exception($expectedMessage, $expectedCode);
     $expected = array('class' => get_class($exception), 'message' => $expectedMessage, 'code' => $expectedCode, 'trace' => $exception->getTraceAsString());
     $this->entity->setFailureException($exception);
     $this->assertEquals($expected, $this->entity->getFailureException());
 }
Example #3
0
 /**
  * Generate rout for entity (using entity config)
  *
  * @param Reminder $reminder
  * @return string
  */
 public function getUrl(Reminder $reminder)
 {
     $metadata = $this->manager->getEntityMetadata($reminder->getRelatedEntityClassName());
     if (isset($metadata)) {
         if (!empty($metadata->routeView)) {
             return $this->router->generate($metadata->routeView, array('id' => $reminder->getRelatedEntityId()));
         }
         if (!empty($metadata->routeName)) {
             return $this->router->generate($metadata->routeName);
         }
     }
     return '';
 }
 /**
  * @param bool  $hasReminder
  * @param bool  $hasConfig
  * @param bool  $hasRecipient
  * @param bool  $hasSender
  * @param array $templates
  * @return EmailNotification
  */
 protected function createNotification($hasReminder = true, $hasConfig = false, $hasRecipient = false, $hasSender = false, $templates = null)
 {
     $repository = $this->getMock('Doctrine\\Common\\Persistence\\ObjectRepository');
     $repository->expects($this->any())->method('find')->will($this->returnValue(new CalendarEvent()));
     $templates = is_array($templates) ? $templates : [$this->createTemplate()];
     $repository->expects($this->any())->method('findBy')->will($this->returnValue($templates));
     $this->em->expects($this->any())->method('getRepository')->will($this->returnValue($repository));
     $this->provider = $this->getMockBuilder('\\Oro\\Bundle\\EntityConfigBundle\\Provider\\ConfigProvider')->disableOriginalConstructor()->getMock();
     $config = $this->getMockBuilder('Oro\\Bundle\\EntityConfigBundle\\Config\\ConfigInterface')->disableOriginalConstructor()->getMock();
     $config->expects($this->any())->method('has')->will($this->returnValue($hasConfig));
     $config->expects($this->any())->method('get')->will($this->returnValue(self::TEMPLATE));
     $this->provider->expects($this->any())->method('getConfig')->will($this->returnValue($config));
     $notification = new EmailNotification($this->em, $this->provider, $this->entityNameResolver);
     if ($hasReminder) {
         $reminder = new Reminder();
         if (!$hasConfig) {
             $reminder->setRelatedEntityClassName(self::ENTITY)->setRelatedEntityId(1);
         }
         if ($hasRecipient) {
             $user = new User();
             $user->setEmail(self::EMAIL);
             $reminder->setRecipient($user);
         }
         if ($hasSender) {
             $reminder->setSender($this->sender);
         }
         $notification->setReminder($reminder);
     }
     return $notification;
 }
 /**
  * @param Reminder $reminder
  * @return string
  */
 protected function getTemplateId(Reminder $reminder)
 {
     $className = $reminder->getRelatedEntityClassName();
     $identifier = $this->configProvider->getConfig($className)->get('reminder_flash_template_identifier');
     return $identifier ?: self::DEFAULT_IDENTIFIER;
 }
Example #6
0
 /**
  * Push reminder to processor
  *
  * @param Reminder $reminder
  */
 public function push(Reminder $reminder)
 {
     $processor = $this->registry->getProcessor($reminder->getMethod());
     $processor->push($reminder);
 }
Example #7
0
 /**
  * Sync reminder with entity data
  *
  * @param Reminder              $reminder
  * @param ReminderDataInterface $reminderData
  * @param string                $entityClass
  * @param mixed                 $entityId
  */
 protected function syncEntityReminder(Reminder $reminder, ReminderDataInterface $reminderData, $entityClass, $entityId)
 {
     $reminder->setReminderData($reminderData);
     $reminder->setRelatedEntityClassName($entityClass);
     $reminder->setRelatedEntityId($entityId);
 }
 /**
  * @param CalendarEvent $calendarEvent
  */
 protected function setReminders(CalendarEvent $calendarEvent)
 {
     if (false === isset($this->options[self::OPTION_KEY_REMINDERS])) {
         return;
     }
     $reminders = new ArrayCollection();
     foreach ($this->options[self::OPTION_KEY_REMINDERS] as $reminder) {
         $reminderEntity = new Reminder();
         $interval = new ReminderInterval($reminder[self::OPTION_REMINDER_KEY_INTERVAL_NUMBER], $reminder[self::OPTION_REMINDER_KEY_INTERVAL_UNIT]);
         $reminderEntity->setSubject($calendarEvent->getTitle())->setExpireAt($calendarEvent->getStart())->setMethod($reminder[self::OPTION_REMINDER_KEY_METHOD])->setInterval($interval)->setRelatedEntityClassName(get_class($calendarEvent))->setRelatedEntityId($calendarEvent->getId())->setRecipient($calendarEvent->getCalendar()->getOwner());
         $this->manager->persist($reminderEntity);
     }
     $calendarEvent->setReminders($reminders);
     foreach ($calendarEvent->getChildEvents() as $childEvent) {
         $this->setReminders($childEvent);
     }
 }