/** * {@inheritdoc} */ public function initialize(ProcessInterface $process, StepInterface $currentStep) { $this->process = $process; $this->currentStep = $currentStep; $this->storage->initialize(md5($process->getScenarioAlias())); $steps = $process->getOrderedSteps(); foreach ($steps as $index => $step) { if ($step === $currentStep) { $this->previousStep = isset($steps[$index - 1]) ? $steps[$index - 1] : null; $this->nextStep = isset($steps[$index + 1]) ? $steps[$index + 1] : null; $this->calculateProgress($index); } } $this->initialized = true; return $this; }
/** * Redirect to step display action. * * @param ProcessInterface $process * @param StepInterface $step * @param ParameterBag $queryParameters * * @return RedirectResponse */ protected function redirectToStepDisplayAction(ProcessInterface $process, StepInterface $step, ParameterBag $queryParameters = null) { $this->context->addStepToHistory($step->getName()); if (null !== ($route = $process->getDisplayRoute())) { $url = $this->router->generate($route, array_merge($process->getDisplayRouteParams(), array('stepName' => $step->getName()), $queryParameters ? $queryParameters->all() : array())); return new RedirectResponse($url); } // Default parameters for display route $routeParameters = array('scenarioAlias' => $process->getScenarioAlias(), 'stepName' => $step->getName()); if (null !== $queryParameters) { $routeParameters = array_merge($queryParameters->all(), $routeParameters); } return new RedirectResponse($this->router->generate('sylius_flow_display', $routeParameters)); }
function it_rewind_history($storage, ProcessInterface $process, StepInterface $currentStep, StepInterface $previousStep, StepInterface $nextStep) { $currentStep->getName()->willReturn('step_two'); $process->getScenarioAlias()->shouldBeCalled(); $storage->initialize(Argument::type('string'))->shouldBeCalled(); $process->getOrderedSteps()->shouldBeCalled()->willReturn(array($previousStep, $currentStep, $nextStep)); $process->countSteps()->shouldBeCalled()->willReturn(2); $this->initialize($process, $currentStep); $storage->get("history", array())->shouldBeCalled()->willreturn(array("step_one", "step_two", "step_three")); $storage->set('history', array('step_one', 'step_two'))->shouldBeCalled(); $this->rewindHistory(); }