Example #1
0
 /**
  * @param DomainEvent $event
  */
 public function validateDefaultLocale(DomainEvent $event)
 {
     $data = $event->getData();
     if ($data !== $this->localeProvider->getDefaultLocale()) {
         return;
     }
     $resource = $event->getResource();
     $event->setStopped(true);
     $event->setStatusCode(409);
     $event->setMessageType('error');
     $event->setMessage($this->translator->trans('lug.' . $resource->getName() . '.' . $event->getAction() . '.default', ['%' . $resource->getName() . '%' => $this->propertyAccessor->getValue($data, $resource->getLabelPropertyPath())], 'flashes'));
 }
Example #2
0
 public function testStopped()
 {
     $this->domainEvent->setStopped(true);
     $this->assertTrue($this->domainEvent->isStopped());
 }
Example #3
0
 /**
  * @param DomainEvent     $event
  * @param string          $action
  * @param string          $state
  * @param \Exception|null $exception
  */
 private function dispatchEvent(DomainEvent $event, $action, $state, \Exception $exception = null)
 {
     if ($state === self::STATE_ERROR) {
         $event->setStopped(true);
     }
     $this->eventDispatcher->dispatch('lug.' . $this->resource->getName() . '.' . $state . '_' . $action, $event);
     if ($event->isStopped()) {
         throw new DomainException($event->getStatusCode(), $event->getMessage(), 0, $exception);
     }
 }