Ejemplo n.º 1
0
 /**
  * @param DomainEvent $event
  */
 public function addMessage(DomainEvent $event)
 {
     $messageType = $event->getMessageType();
     $message = $event->getMessage();
     if (empty($messageType)) {
         $messageType = $event->isStopped() ? 'error' : 'success';
     }
     if (empty($message)) {
         $object = $event->getObject();
         $resource = $event->getResource();
         $name = $resource->getName();
         $labelPropertyPath = $resource->getLabelPropertyPath();
         $property = $labelPropertyPath !== null ? $this->propertyAccessor->getValue($object, $labelPropertyPath) : (string) $object;
         $message = $this->translator->trans('lug.' . $name . '.' . $event->getAction() . '.' . $messageType, ['%' . $name . '%' => $property], 'flashes');
     }
     $event->setMessageType($messageType);
     $event->setMessage($message);
 }
Ejemplo n.º 2
0
 /**
  * @param DomainEvent $event
  */
 public function addMessage(DomainEvent $event)
 {
     if ($this->parameterResolver->resolveApi()) {
         return;
     }
     $messageType = $event->getMessageType();
     $message = $event->getMessage();
     if (empty($messageType)) {
         $messageType = $event->isStopped() ? 'error' : 'success';
     }
     if (empty($message)) {
         $data = $event->getData();
         $resource = $event->getResource();
         $name = $resource->getName();
         $labelPropertyPath = $resource->getLabelPropertyPath();
         $property = $labelPropertyPath !== null ? $this->propertyAccessor->getValue($data, $labelPropertyPath) : (string) $data;
         $message = $this->translator->trans('lug.' . $name . '.' . $event->getAction() . '.' . $messageType, ['%' . $name . '%' => $property], 'flashes');
     }
     $event->setMessageType($messageType);
     $event->setMessage($message);
 }
Ejemplo n.º 3
0
 public function testStopped()
 {
     $this->domainEvent->setStopped(true);
     $this->assertTrue($this->domainEvent->isStopped());
 }