/** * This is the callback function for ALL flows that the flow module responds to. * All flow processing starts here. * * Request Params supported: * _fid - the id of the flow * _faction - the name of the action that the user is taking * */ function requestAction() { $url = parse_url($this->getRequest()->getRequestUri()); $uri = $url['path']; $flowFile = $this->getFlowFile(); // Pull the flowId out of the request $flowId = $this->_getParam('_fid'); $action = $this->_getParam('_faction'); $flow = null; $session = new Zend_Session_Namespace('flow'); // If the flowId exists on the request then try to continue the existing flow if (!empty($flowId)) { $flow = unserialize($session->{$flowId}); $this->flow = $flow; } // If no existing flow then create a new one and stick it in the session if (empty($flow)) { $flow = new Flow($flowFile, $uri, $this, $this->_request->getControllerName()); $this->flow = $flow; $flow->process("__INIT__"); } // Have to always set the controller, because we serialize it but the next request will have a // Different one $flow->controller = $this; $flowId = $flow->id; // If the user actually tried to do something other than refresh the page if (!empty($action)) { // Process the action $flow->process($action); // Store the result in the session $session->{$flowId} = serialize($flow); // Redirect so that the user can refresh, without warnings from the browser $this->_helper->redirector->gotoUrl($uri . "?_fid={$flow->id}"); } // Otherwise, we will just render using the same state info. // Store the result in the session $session->{$flowId} = serialize($flow); $flow->render(); $session->{$flowId} = serialize($flow); }