Exemplo n.º 1
0
 /**
  * Render an Walkthrough
  *
  * @param $id
  * @param $slug
  * @param $stepNumber
  * @param $stepSlug
  *
  * @return WalkthroughView
  */
 public function renderWalkthrough($id, $slug, $stepNumber, $stepSlug)
 {
     $walkthrough = new Walkthrough($id);
     if (!$walkthrough->exists()) {
         return $this->renderNotFound();
     }
     $step = $walkthrough->getStep($stepNumber);
     if (!$step) {
         return $this->renderNotFound();
     }
     /** @var WalkthroughView $view */
     $view = $this->getMapperView($walkthrough, 'WalkthroughView');
     $view->setWalkthrough($walkthrough);
     $view->setCurrentStep($step);
     // Set the title
     $view->setTitle(sprintf('%s - %s', $walkthrough->title, $step->title));
     return $this->setView($view);
 }
Exemplo n.º 2
0
 /**
  * Add example walkthroughs
  *
  * @return $this
  */
 protected function _addWalkthroughs()
 {
     $count = 0;
     echo 'Adding Walkthroughs: ';
     $categories = Category::collection();
     foreach ($categories as $category) {
         $walkthroughTitles = $this->_getTitleArray('Walkthrough', rand(1, 3));
         foreach ($walkthroughTitles as $walkthroughTitle) {
             $walkthrough = new Walkthrough();
             $walkthrough->categoryId = $category->id();
             $walkthrough->title = $walkthroughTitle;
             $walkthrough->slug = Strings::urlize($walkthroughTitle);
             $walkthrough->subTitle = $this->_getExampleContent(rand(4, 8));
             $walkthrough->description = $this->_getExampleContent(rand(10, 20));
             $walkthrough->saveChanges();
             $stepTitles = $this->_getTitleArray(rand(3, 6));
             $stepOrder = 1;
             foreach ($stepTitles as $stepTitle) {
                 $step = new WalkthroughStep();
                 $step->title = sprintf('Step %d: %s', $stepOrder, $stepTitle);
                 $step->slug = Strings::urlize($stepTitle);
                 $step->walkthroughId = $walkthrough->id();
                 $step->content = $this->_getExampleContent(rand(30, 50));
                 $step->order = $stepOrder;
                 $step->saveChanges();
                 $stepOrder++;
             }
             $count++;
         }
     }
     echo $count . PHP_EOL;
     return $this;
 }