public function bind(\Nethgui\Controller\RequestInterface $request) { parent::bind($request); $this->position = $this->bindPosition($request); if (intval($this->position) <= 0) { throw new \Nethgui\Exception\HttpException('Not found', 404, 1399992980); } $subrequest = $request->spawnRequest($this->position); if ($subrequest->hasParameter('f') || $subrequest->hasParameter('Submit')) { $this->workflow->resume($this->getParent()->getSession()); } else { // start a new workflow generating a random rule key $defaults = $this->getRuleDefaults(); foreach (array('SrcRaw', 'DstRaw', 'ServiceRaw', 'status', 'Description', 'LogType', 'Action') as $f) { if ($request->hasParameter($f)) { $defaults[$f] = $request->getParameter($f); } } $this->workflow->start($this->getParent()->getSession(), $this->getIdentifier(), $this->getIdentifier() . '/' . $this->position, $this->generateNextRuleId(), $defaults); } $this->worker->ruleId = $this->workflow->getRuleId(); $this->worker->bind($request); $this->workflow->copyTo($this->worker->parameters, array('SrcRaw', 'DstRaw', 'ServiceRaw', 'status', 'Description', 'LogType', 'Action')); if ($request->isMutation()) { $this->worker->parameters['Position'] = $this->position; } }
public function bind(\Nethgui\Controller\RequestInterface $request) { $ruleId = \Nethgui\array_head($request->getPath()); if (!$this->getAdapter()->offsetExists($ruleId)) { throw new \Nethgui\Exception\HttpException('Not found', 404, 1399992975); } $this->worker->ruleId = $ruleId; $this->worker->bind($request); $subrequest = $request->spawnRequest($ruleId); if ($subrequest->hasParameter('f') || $subrequest->hasParameter('Submit')) { // resume values from $this->workflow->resume($this->getParent()->getSession())->copyTo($this->worker->parameters, array('SrcRaw', 'DstRaw', 'ServiceRaw', 'status', 'Description', 'LogType', 'Action')); } else { // start new workflow $defaults = array(); foreach (array('SrcRaw', 'DstRaw', 'ServiceRaw', 'status', 'Description', 'LogType', 'Action') as $f) { if ($request->hasParameter($f)) { $defaults[$f] = $request->getParameter($f); } } $this->workflow->start($this->getParent()->getSession(), $this->getIdentifier(), 'Edit/' . $ruleId, $ruleId, $defaults); } }