Пример #1
0
 public function preTransition(TransitionEventArgs $eventArgs)
 {
     $this->calls['preTransition'] = $eventArgs;
     if ($this->rollbackTransition) {
         $eventArgs->setReject(true);
     }
 }
 /**
  *
  * @param  \Zoop\Shard\State\TransitionEventArgs $eventArgs
  * @return type
  */
 public function preTransition(TransitionEventArgs $eventArgs)
 {
     if (!($accessController = $this->getAccessController())) {
         //Access control is not enabled
         return;
     }
     $document = $eventArgs->getDocument();
     $eventManager = $eventArgs->getEventManager();
     $action = $eventArgs->getTransition()->getAction();
     $metadata = $eventArgs->getMetadata();
     if (!$accessController->areAllowed([$action], $metadata, $document, $eventArgs->getChangeSet())->getAllowed()) {
         //stop transition
         $metadata->setFieldValue($document, array_keys($metadata->getState())[0], $eventArgs->getTransition()->getFrom());
         $eventManager->dispatchEvent(Events::TRANSITION_DENIED, $eventArgs);
     }
 }