Ejemplo n.º 1
0
 public function __invoke(SiteTreeNodeInterface $page)
 {
     if ($this->hasPluginForDispatcher($page->getPageTypeId())) {
         return;
     }
     $this->bootPlugin($page->getPageTypeId());
 }
Ejemplo n.º 2
0
 public function finalizeSave(Form $form, SiteTreeNodeInterface $model)
 {
     $config = $this->configModel()->getConfig($model->getPageTypeId(), $model->getIdentifier());
     foreach ($form->getData($this->fieldPrefix()) as $key => $value) {
         $config->set($key, $value);
     }
     $this->configModel()->saveConfig($config, $model->id);
 }
Ejemplo n.º 3
0
 protected function getPageType(SiteTreeNodeInterface $node)
 {
     return $this->pageTypes->get($node->getPageTypeId());
 }
Ejemplo n.º 4
0
 /**
  * Convert a root node to a scope
  *
  * @param \Cmsable\Model\SiteTreeNodeInterface $node
  * @return \Cmsable\Routing\TreeScope\TreeScope
  **/
 public function node2Scope(SiteTreeNodeInterface $node)
 {
     $scope = new TreeScope();
     $urlSegment = trim($node->getUrlSegment(), '/');
     $name = $urlSegment ? $urlSegment : TreeScope::DEFAULT_NAME;
     $scope->setPathPrefix($node->getUrlSegment());
     $scope->setName($name);
     $scope->setTitle($node->getMenuTitle());
     $scope->setModelRootId($node->{$this->treeModel->rootCol()});
     return $scope;
 }
Ejemplo n.º 5
0
 protected function calculateRedirectPath(SiteTreeNodeInterface $redirect, $filter = 'default')
 {
     if ($redirect->getRedirectType() == SiteTreeNodeInterface::EXTERNAL) {
         return $redirect->getRedirectTarget();
     }
     if ($redirect->getRedirectType() == SiteTreeNodeInterface::INTERNAL) {
         $target = $redirect->getRedirectTarget();
         if (is_numeric($target)) {
             if ($targetPage = $this->siteTreeModel->pageById((int) $target)) {
                 if ($targetPage->getRedirectType() == SiteTreeNodeInterface::NONE) {
                     return $this->cleanHomePath($targetPage->getPath());
                 } else {
                     return '_error_';
                 }
             } elseif ($targetPage = $this->siteTreeModel->newNode()->find((int) $target)) {
                 if (!($treeModel = $this->modelForPage($targetPage))) {
                     return '_error_';
                 }
                 if (!($assignedPage = $treeModel->pageById((int) $target))) {
                     return;
                 }
                 return $this->cleanHomePath($assignedPage->getPath());
             }
         } elseif ($target == SiteTreeNodeInterface::FIRST_CHILD) {
             if ($redirect->hasChildNodes()) {
                 if ($child = $this->findFirstNonRedirectChild($redirect->filteredChildren($filter), $filter)) {
                     return $child->getPath();
                 } else {
                     return '_error_';
                 }
             }
         }
     }
     return '_error_';
 }
Ejemplo n.º 6
0
 protected function toArray(Node $node, $routeName)
 {
     return ['id' => $node->getIdentifier(), 'path' => $node->getPath(), 'menu_title' => $node->getMenuTitle(), 'title' => $node->getTitle(), 'content' => $node->getContent(), 'routeName' => $routeName];
 }