コード例 #1
0
 public function preTransition(StateEventArgs $eventArgs)
 {
     $this->calls['preTransition'] = $eventArgs;
     if ($this->rollbackTransition) {
         $eventArgs->getDocument()->setState($eventArgs->getTransition()->getFrom());
     }
 }
 /**
  *
  * @param \Doctrine\ODM\MongoDB\Event\OnFlushEventArgs $eventArgs
  */
 public function preTransition(TransitionEventArgs $eventArgs)
 {
     if (!($accessController = $this->getAccessController())) {
         //Access control is not enabled
         return;
     }
     $document = $eventArgs->getDocument();
     $documentManager = $eventArgs->getDocumentManager();
     $eventManager = $documentManager->getEventManager();
     $action = $eventArgs->getTransition()->getAction();
     if (!$accessController->isAllowed($action, null, $document)->getIsAllowed()) {
         //stop transition
         $document->setState($eventArgs->getTransition()->getFrom());
         $eventManager = $eventArgs->getDocumentManager()->getEventManager();
         if ($eventManager->hasListeners(Events::transitionDenied)) {
             $eventManager->dispatchEvent(Events::transitionDenied, $eventArgs);
         }
     }
 }