/** * Invokes the plugin specific code. * * @return string * @throws Stagehand_LegacyError_PEARErrorStack_Exception */ public function invoke() { $this->_prepareContinuation(); Piece_Unity_Service_Continuation::setFlowExecutionTicketKey($this->flowExecutionTicketKey); self::$_flowID = $this->context->getOriginalScriptName(); Piece_Flow_Action_Factory::setActionDirectory($this->actionDirectory); $viewElement = $this->context->viewElement; $viewElement->setElement('__flowExecutionTicketKey', Piece_Unity_Service_Continuation::getFlowExecutionTicketKey()); try { $flowExecutionTicket = $this->_continuationServer->invoke($this->context, $this->bindActionsWithFlowExecution); $viewString = $this->_continuationServer->getView(); } catch (Stagehand_LegacyError_PEARErrorStack_Exception $e) { if ($e->getCode() == PIECE_FLOW_ERROR_FLOW_EXECUTION_EXPIRED) { if ($this->useGCFallback) { $session = $this->context->getSession(); $session->setAttribute('_flowExecutionExpired', true); $this->context->sendHTTPStatus(302); return $this->gcFallbackURI; } } throw $e; } $this->context->viewElement->setElement('__flowExecutionTicket', $flowExecutionTicket); $session = $this->context->getSession(); $session->setPreloadCallback('_Dispatcher_Continuation_ActionLoader', array(__CLASS__, 'loadAction')); foreach (array_keys(Piece_Flow_Action_Factory::getInstances()) as $actionClass) { $session->addPreloadClass('_Dispatcher_Continuation_ActionLoader', $actionClass, $this->_continuationServer->getActiveFlowID()); } return $this->_prefixFlowNameToViewString($viewString); }
/** * 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']); }
/** * 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; }