/** * {@inheritdoc} */ public function getActiveNodeTypes(NodeInterface $node) { $nodeTypes = array(); foreach ($this->nodeTypeRegistry->getConfigs() as $config) { if ($node->getType() === $config->getType() || $this->nodeValidator->validateByOnlyOne($config->getType(), $node->getTree()) && (!$config->getParentTypes() || $this->nodeValidator->validateByParent($config->getType(), $node->getParent()))) { $nodeTypes[$config->getType()] = $config->getType(); } } return array_values($nodeTypes); }
/** * Process node delete. * * @param NodeInterface $node * @param Request $request * * @return bool */ public function process(NodeInterface $node, Request $request) { if (null !== $node->getParent() && $request->isMethod('DELETE')) { $event = $this->createTreeNodeEvent($request->getLocale(), $node); $this->eventDispatcher->dispatch(TadckaTreeEvents::NODE_PRE_DELETE, $event); $this->nodeManager->remove($node, true); return true; } return false; }
/** * Check if node parent is online. * * @param NodeInterface $node * @param string $locale * * @return bool */ private function parentIsOnline(NodeInterface $node, $locale) { $parent = $node->getParent(); if (null !== $parent && $this->routeHelper->hasController($parent->getType())) { if (false === $this->routeHelper->hasRoute($locale, $node)) { return false; } if (null === ($translation = $parent->getTranslation($locale))) { return false; } if (null === ($route = $translation->getRoute())) { return false; } return $route->isVisible(); } return true; }
/** * Get route full path. * * @param NodeInterface $node * @param string $locale * * @return string */ private function getRouteFullPath(NodeInterface $node, $locale) { $path = ''; if ($this->hasController($node->getType())) { $parent = $node->getParent(); if (null !== $parent && $this->hasController($parent->getType())) { $path = $this->getRouteFullPath($parent, $locale); } if (null !== ($translation = $node->getTranslation($locale))) { $path .= $this->normalizeRoutePattern($translation->getTitle()); } } return $path; }
/** * Get node icon. * * @param NodeInterface $node * * @return null|string */ private function getIcon(NodeInterface $node) { if (null === $node->getParent()) { return $this->getRootNodeIcon(); } if ($node->getType() && null !== ($config = $this->nodeProvider->getNodeTypeConfig($node->getType()))) { return $config->getIconPath(); } return null; }
/** * Get node types. * * @param NodeInterface $node * * @return array */ private function getNodeTypes(NodeInterface $node) { $nodeTypes = array(); if (null !== $node->getParent()) { foreach ($this->nodeProvider->getActiveNodeTypes($node) as $nodeType) { $nodeTypes[$nodeType] = $this->getNodeTypeName($this->nodeProvider->getNodeTypeConfig($nodeType)); } } return $nodeTypes; }
/** * {@inheritdoc} */ public function increase(NodeInterface $node) { $node->setPriority(1 + $this->getMaxPriority($node->getParent())); }