Esempio n. 1
0
 /**
  * Test methods
  */
 public function testMethods()
 {
     $form = new Form();
     $step = new WizardStep();
     $step->setStepForm($form);
     $this->assertSame($form, $step->getStepForm());
     $step->setTextDomain('exampleTextDomain');
     $this->assertSame('exampleTextDomain', $step->getTextDomain());
     $step->setDescriptionPartial('exampleDescriptionPartial');
     $this->assertSame('exampleDescriptionPartial', $step->getDescriptionPartial());
     $this->assertFalse($step->canFinishWizard());
     $this->assertTrue($step->canCancelWizard());
     $this->assertFalse($step->canSkip());
     $step->setOption('finish', true);
     $step->setOption('cancel', false);
     $step->setOption('skip', true);
     $this->assertTrue($step->canFinishWizard());
     $this->assertFalse($step->canCancelWizard());
     $this->assertTrue($step->canSkip());
     $this->assertFalse($step->hasPreviousStep());
     $step->setPreviousStep('examplePreviousStep');
     $this->assertSame('examplePreviousStep', $step->getPreviousStep());
     $this->assertTrue($step->hasPreviousStep());
     $this->assertFalse($step->hasNextStep());
     $step->setNextStep('exampleNextStep');
     $this->assertSame('exampleNextStep', $step->getNextStep());
     $this->assertTrue($step->hasNextStep());
 }
 /**
  * Get step model
  *
  * @param   string $step
  * @return  \Core\View\Model\WizardStep
  */
 protected function getStep($step)
 {
     $model = new WizardStep(array('textDomain' => 'central'));
     switch ($step) {
         case $this->startStep:
             $auth = $this->getAuthenticationService();
             $model->setOptions(array('finish' => false, 'next' => $auth->hasIdentity() ? 'layout' : 'user'));
             break;
         case 'user':
             $model->setOptions(array('finish' => false, 'next' => 'layout'));
             break;
         case 'layout':
             $settings = $this->getStepStore('settings');
             if (empty($settings)) {
                 $start = $this->getStepStore($this->startStep);
                 $this->setStepStore('settings', array('headTitle' => $start['subdomain'], 'keywords' => $start['subdomain'], 'description' => $start['subdomain']));
             }
             $model->setOptions(array('finish' => false, 'next' => 'content'));
             break;
         case 'content':
             $model->setOptions(array('finish' => true, 'next' => 'settings'));
             break;
         case 'settings':
             $auth = $this->getAuthenticationService();
             $model->setOptions(array('finish' => true, 'next' => $auth->hasIdentity() ? 'check' : 'finish'));
             break;
         case 'check':
             $expired = false;
             $hash = $this->params()->fromQuery('hash');
             if (!empty($hash)) {
                 $data = $this->getServiceLocator()->get('Grid\\MultisiteCentral\\Model\\SiteWizardData');
                 if ($data->has($hash)) {
                     $this->unsetStepStack();
                     foreach ($data->get($hash) as $stepName => $values) {
                         $this->pushStepStack($stepName);
                         $this->setStepStore($stepName, $values);
                     }
                     // $data->delete( $hash );
                 } else {
                     $expired = true;
                 }
             }
             if ($expired) {
                 $model->setDescriptionPartial('grid/multisite-central/site-wizard/expired')->setOptions(array('finish' => false, 'next' => $this->startStep));
             } else {
                 $postfix = $this->getServiceLocator()->get('Config')['modules']['Grid\\MultisiteCentral']['domainPostfix'];
                 $model->setVariable('stores', $this->getStepStores(false))->setVariable('domainPostfix', $postfix)->setDescriptionPartial('grid/multisite-central/site-wizard/check')->setOptions(array('finish' => true, 'next' => 'finish'));
             }
             break;
         default:
             throw new RuntimeException('Step: ' . $step . ' is not supported');
     }
     if ($step == 'check') {
         $model->setStepForm(new Form());
     } else {
         $model->setDescriptionPartial('grid/multisite-central/site-wizard/description')->setStepForm($this->getServiceLocator()->get('Form')->get('Grid\\MultisiteCentral\\SiteWizard\\' . ucfirst($step)));
     }
     return $model;
 }