/** * 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(); }
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; }
/** * 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; }