Exemplo n.º 1
0
 /**
  * Add success or error message to session.
  *
  * @param Array   $args    arguments from handleCommand method.
  * @param Boolean $success true if this is a success, false for default error.
  *
  * @throws RuntimeException Thrown if executing the workflow action fails
  */
 protected function addDefaultMessage($args, $success = false)
 {
     $message = $this->getDefaultMessage($args, $success);
     if (!empty($message)) {
         $flashType = $success === true ? 'status' : 'error';
         $this->request->getSession()->getFlashBag()->add($flashType, $message);
         $logger = $this->view->getServiceManager()->get('logger');
         if ($success === true) {
             $logger->notice('{app}: User {user} updated the {entity} with id {id}.', array('app' => 'ZikulaRoutesModule', 'user' => UserUtil::getVar('uname'), 'entity' => $this->objectType, 'id' => $this->entityRef->createCompositeIdentifier()));
         } else {
             $logger->error('{app}: User {user} tried to update the {entity} with id {id}, but failed.', array('app' => 'ZikulaRoutesModule', 'user' => UserUtil::getVar('uname'), 'entity' => $this->objectType, 'id' => $this->entityRef->createCompositeIdentifier()));
         }
     }
 }
Exemplo n.º 2
0
 /**
  * Executes a certain workflow action for a given entity object.
  *
  * @param \Zikula_EntityAccess $entity   The given entity instance.
  * @param string               $actionId Name of action to be executed.
  * @param bool                 $recursive true if the function called itself.  
  *
  * @return bool False on error or true if everything worked well.
  */
 public function executeAction($entity, $actionId = '', $recursive = false)
 {
     $objectType = $entity['_objectType'];
     $schemaName = $this->getWorkflowName($objectType);
     $entity->initWorkflow(true);
     $idcolumn = $entity['__WORKFLOW__']['obj_idcolumn'];
     $result = Zikula_Workflow_Util::executeAction($schemaName, $entity, $actionId, $objectType, $this->name, $idcolumn);
     if ($result !== false && !$recursive) {
         $entities = $entity->getRelatedObjectsToPersist();
         foreach ($entities as $rel) {
             if ($rel->getWorkflowState() == 'initial') {
                 $this->executeAction($rel, $actionId, true);
             }
         }
     }
     return $result !== false;
 }