Пример #1
0
 public function testBuildPageWithTemplateTemplate()
 {
     $builder = new WidgetMapBuilder();
     $grandtemplate = new Template();
     $template = new Template();
     $template->setTemplate($grandtemplate);
     $view = new Page();
     $view->setTemplate($template);
     $widget3 = $this->newWidgetMap(3, null, null, $grandtemplate, $this->newWidget(3));
     $widget2 = $this->newWidgetMap(2, $widget3, WidgetMap::POSITION_BEFORE, $template, $this->newWidget(2));
     $widget1 = $this->newWidgetMap(1, $widget2, WidgetMap::POSITION_AFTER, $view, $this->newWidget(1));
     $widget4 = $this->newWidgetMap(4, $widget3, WidgetMap::POSITION_AFTER, $view, $this->newWidget(4));
     $builtWidgetMap = $builder->build($view);
     $order = [2, 1, 3, 4];
     $i = 0;
     foreach ($builtWidgetMap['content'] as $widgetMap) {
         $this->assertEquals($order[$i++], $widgetMap->getWidget()->getId());
     }
 }
 /**
  * Transforms an object (issue) to a string (number).
  *
  * @param Page $page
  *
  * @return Template
  */
 public function transform($page)
 {
     if ($page instanceof Template) {
         return $page;
     }
     $template = new Template();
     $template->setName($page->getName());
     $template->setSlug($page->getSlug());
     $template->setLayout($page->getTemplate()->getLayout());
     $template->setWidgets($page->getWidgets());
     $template->setWidgetMap($page->getWidgetMap());
     $page->setTemplate($template);
     return $template;
 }
Пример #3
0
 /**
  * contruct.
  **/
 public function __construct()
 {
     parent::__construct();
     $this->publishedAt = new \DateTime();
     $this->status = PageStatus::PUBLISHED;
 }