コード例 #1
0
 /**
  * Transforms an object (Page) to a string (id).
  *
  * @param  Page|null $page
  * @return string
  */
 public function transform($page)
 {
     if (null === $page) {
         return "";
     }
     return $page->getId();
 }
コード例 #2
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());
     }
 }
コード例 #3
0
 /**
  * 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;
 }
コード例 #4
0
ファイル: PageHelper.php プロジェクト: global01/victoire
 /**
  * Create an instance of the business entity page.
  *
  * @param BusinessTemplate $BusinessTemplate The business entity page
  * @param entity           $entity           The entity
  * @param string           $url              The new url
  *
  * @return \Victoire\Bundle\PageBundle\Entity\Page
  */
 public function createPageInstanceFromBusinessTemplate(BusinessTemplate $BusinessTemplate, $entity, $url)
 {
     //create a new page
     $newPage = new Page();
     $parentPage = $BusinessTemplate->getParent();
     //set the page parameter by the business entity page
     $newPage->setParent($parentPage);
     $newPage->setTemplate($BusinessTemplate);
     $newPage->setUrl($url);
     $newPage->setTitle($BusinessTemplate->getTitle());
     //update the parameters of the page
     $this->businessPageBuilder->updatePageParametersByEntity($newPage, $entity);
     $businessEntity = $this->businessEntityHelper->findByEntityInstance($entity);
     $entityProxy = new EntityProxy();
     $entityProxy->setEntity($entity, $businessEntity->getName());
     $newPage->setEntityProxy($entityProxy);
     return $newPage;
 }