public function process() { if (!$this->wizard || !$this->request->isPost()) { return; } $post = $this->request->getPost(); $values = $post->getArrayCopy(); if (isset($values['previous'])) { $this->wizard->previousStep(); return; } if (isset($values['cancel'])) { return $this->doCancel(); } $this->processCurrentStep($values); $steps = $this->wizard->getSteps(); $currentStep = $this->wizard->getCurrentStep(); if (!$currentStep->isComplete()) { return; } if ($currentStep->isComplete() && $steps->isLast($currentStep)) { return $this->completeWizard(); } $this->wizard->nextStep(); }
/** * @param ServiceLocatorInterface $serviceLocator * @return Wizard */ public function createService(ServiceLocatorInterface $serviceLocator) { /* @var $wizard \Wizard\WizardInterface */ $wizard = new Wizard(); $formFactory = $serviceLocator->get('Wizard\\Form\\FormFactory'); $wizard->setFormFactory($formFactory); $wizardProcessor = $serviceLocator->get('Wizard\\WizardProcessor'); $wizard->setWizardProcessor($wizardProcessor); $identifierAccessor = $serviceLocator->get('Wizard\\Wizard\\IdentifierAccessor'); $wizard->setIdentifierAccessor($identifierAccessor); $wizardListener = $serviceLocator->get('Wizard\\Listener\\WizardListener'); $wizard->getEventManager()->attachAggregate($wizardListener); $stepCollection = $wizard->getSteps(); $stepCollectionListener = $serviceLocator->get('Wizard\\Listener\\StepCollectionListener'); $stepCollection->getEventManager()->attachAggregate($stepCollectionListener); return $wizard; }
public function testSetAndGetStepCollection() { $wizard = new Wizard(); $this->assertInstanceOf('Wizard\\Step\\StepCollection', $wizard->getSteps()); }