Example #1
0
 public function register(ManagedRepositoryInterface $repository, ControllerNodeInterface $node, $isRootNode = false)
 {
     $this->nodes[$repository->getClassName()][$node->getActionName()] = $node;
     if ($isRootNode) {
         $this->nodes[$repository->getClassName()]['_root'] = $node;
     }
 }
 public function __construct(ManagedRepositoryInterface $repository, UrlGeneratorInterface $urlGenerator, ControllerNodeInterface $currentControllerNode = null, $routeName = 'cms')
 {
     $rootNode = $repository->queryMetadata('getRootCmsNode');
     parent::__construct($rootNode, $routeName, $urlGenerator);
     $this->repository = $repository;
     $this->currentControllerNode = $currentControllerNode;
     $diff = $currentControllerNode === null ? [] : [$currentControllerNode->getActionName() => null];
     foreach (array_diff(['index', 'add'], array_keys($diff)) as $action) {
         if (!$this->hasChild($action) && $repository->queryMetadata('hasCmsNode', compact('action'))) {
             $node = $repository->queryMetadata('getCmsNode', compact('action'));
             $listNode = $this->createListNode($node);
             $this->wrapChild($listNode, $action, $node->getActionLabel(), false);
         }
     }
     $this->childNodes = array_diff_key($this->childNodes, $diff);
 }