Ejemplo n.º 1
0
 /**
  * Creates an action object from a configuration file or a cache.
  *
  * @param string $class
  * @return mixed
  */
 function &factory($class)
 {
     if (!array_key_exists($GLOBALS['PIECE_FLOW_Action_ContextID'], $GLOBALS['PIECE_FLOW_Action_Instances']) || !array_key_exists($class, $GLOBALS['PIECE_FLOW_Action_Instances'][$GLOBALS['PIECE_FLOW_Action_ContextID']])) {
         Piece_Flow_Action_Factory::load($class);
         if (Piece_Flow_Error::hasErrors()) {
             $return = null;
             return $return;
         }
         $GLOBALS['PIECE_FLOW_Action_Instances'][$GLOBALS['PIECE_FLOW_Action_ContextID']][$class] =& new $class();
     }
     return $GLOBALS['PIECE_FLOW_Action_Instances'][$GLOBALS['PIECE_FLOW_Action_ContextID']][$class];
 }
Ejemplo n.º 2
0
 /**
  * Defines and initializes extension points and configuration points.
  *
  * @since Method available since Release 0.6.0
  */
 function _initialize()
 {
     $this->_addConfigurationPoint('actionDirectory');
     $this->_addConfigurationPoint('enableSingleFlowMode', false);
     // deprecated
     $this->_addConfigurationPoint('cacheDirectory');
     $this->_addConfigurationPoint('flowDefinitions', array());
     // deprecated
     $this->_addConfigurationPoint('flowExecutionTicketKey', '_flowExecutionTicket');
     $this->_addConfigurationPoint('flowNameKey', '_flow');
     // deprecated
     $this->_addConfigurationPoint('flowName');
     // deprecated
     $this->_addConfigurationPoint('bindActionsWithFlowExecution', true);
     $this->_addConfigurationPoint('enableGC', false);
     $this->_addConfigurationPoint('gcExpirationTime', 1440);
     $this->_addConfigurationPoint('useGCFallback', false);
     $this->_addConfigurationPoint('gcFallbackURL');
     // deprecated
     $this->_addConfigurationPoint('useFlowMappings', false);
     $this->_addConfigurationPoint('flowMappings', array());
     $this->_addConfigurationPoint('configDirectory');
     $this->_addConfigurationPoint('configExtension', '.flow');
     $this->_addConfigurationPoint('useFullFlowNameAsViewPrefix', true);
     $this->_addConfigurationPoint('gcFallbackURI', $this->_getConfiguration('gcFallbackURL'));
     Piece_Unity_Service_Continuation::setFlowExecutionTicketKey($this->_getConfiguration('flowExecutionTicketKey'));
     $GLOBALS['PIECE_UNITY_Continuation_FlowIDKey'] = $this->_getConfiguration('flowNameKey');
     if ($this->_getConfiguration('useFlowMappings')) {
         $GLOBALS['PIECE_UNITY_Continuation_FlowID'] = $this->_context->getOriginalScriptName();
     } else {
         $GLOBALS['PIECE_UNITY_Continuation_FlowID'] = $this->_getConfiguration('flowName');
     }
     Piece_Flow_Action_Factory::setActionDirectory($this->_getConfiguration('actionDirectory'));
     $viewElement =& $this->_context->getViewElement();
     $viewElement->setElement('__flowExecutionTicketKey', Piece_Unity_Service_Continuation::getFlowExecutionTicketKey());
     $viewElement->setElement('__flowNameKey', $GLOBALS['PIECE_UNITY_Continuation_FlowIDKey']);
 }
Ejemplo n.º 3
0
 /**
  * Prepares the context by flow execution ticket.
  *
  * @since Method available since Release 1.15.0
  */
 function _prepareContext()
 {
     if ($this->_useContext) {
         Piece_Flow_Action_Factory::setContextID($this->_activeFlowExecutionTicket);
     } else {
         Piece_Flow_Action_Factory::clearContextID();
     }
 }
Ejemplo n.º 4
0
 /**
  * Loads an action for preventing that the action become an incomplete class.
  *
  * @param string $class
  * @param string $flowID
  */
 public static function loadAction($class, $flowID)
 {
     if ($flowID == Piece_Unity_Plugin_Dispatcher_Continuation::getFlowID()) {
         Piece_Flow_Action_Factory::load($class);
     }
 }
Ejemplo n.º 5
0
 /**
  * Continues a flow execution.
  *
  * @param mixed   &$payload
  * @param boolean $bindActionsWithFlowExecution
  * @throws PIECE_FLOW_ERROR_FLOW_EXECUTION_EXPIRED
  */
 function _continue(&$payload, $bindActionsWithFlowExecution)
 {
     if ($this->_enableGC) {
         if ($this->_gc->isMarked($this->_currentFlowExecutionTicket)) {
             $this->_removeFlowExecution($this->_currentFlowExecutionTicket, $this->_currentFlowName);
             Piece_Flow_Error::push(PIECE_FLOW_ERROR_FLOW_EXECUTION_EXPIRED, 'The flow execution for the given flow execution ticket has expired.');
             return;
         }
     }
     $this->_activated = true;
     $this->_flowExecutions[$this->_currentFlowExecutionTicket]->setPayload($payload);
     if ($bindActionsWithFlowExecution) {
         Piece_Flow_Action_Factory::setInstances($this->_flowExecutions[$this->_currentFlowExecutionTicket]->getAttribute('_actionInstances'));
     }
     $this->_flowExecutions[$this->_currentFlowExecutionTicket]->triggerEvent(call_user_func($this->_eventNameCallback));
 }
Ejemplo n.º 6
0
 /**
  * Invokes an event handler in an action.
  *
  * @param string $eventName
  * @param mixed  &$payload
  * @return string
  * @throws PIECE_FLOW_ERROR_NOT_FOUND
  */
 function _invokeEventHandler($eventName, &$payload)
 {
     if (!is_null($this->_actionDirectory)) {
         Piece_Flow_Action_Factory::setActionDirectory($this->_actionDirectory);
     }
     $action =& Piece_Flow_Action_Factory::factory($this->_class);
     if (Piece_Flow_Error::hasErrors()) {
         return;
     }
     if (!method_exists($action, $this->_method)) {
         Piece_Flow_Error::push(PIECE_FLOW_ERROR_NOT_FOUND, "The method [ {$this->_method} ] does not exist in the action class [ {$this->_class} ].");
         return;
     }
     if (method_exists($action, 'setFlow')) {
         $action->setFlow($this->_flow);
     }
     if (method_exists($action, 'setPayload')) {
         $action->setPayload($payload);
     }
     if (method_exists($action, 'setEvent')) {
         $action->setEvent($eventName);
     }
     if (method_exists($action, 'prepare')) {
         $action->prepare();
     }
     $result = call_user_func(array(&$action, $this->_method));
     if (method_exists($action, 'clear')) {
         $action->clear();
     }
     return $result;
 }