/** * @param NodeInterface $node */ protected function deleteRedirectionForNodeTree(NodeInterface $node) { $this->redirectionManager->deleteRedirection($node->getNodeId(), $node->getLanguage(), $node->getSiteId()); $nodes = $this->nodeRepository->findByParent($node->getNodeId(), $node->getSiteId()); foreach ($nodes as $node) { $this->deleteRedirectionForNodeTree($node); } }
/** * Checks if the passed value is valid. * * @param NodeInterface $value The value that should be validated * @param Constraint $constraint The constraint for the validation * * @api */ public function validate($value, Constraint $constraint) { $result = $this->repository->hasOtherNodeWithSameParentAndOrder($value->getParentId(), $value->getOrder(), $value->getNodeId(), $value->getSiteId()); if (true === $result) { $this->context->buildViolation($constraint->message)->addViolation(); } }
/** * @param NodeInterface $node */ public function restore($node) { $nodes = $this->nodeRepository->findByNodeAndSite($node->getNodeId(), $node->getSiteId()); /** @var NodeInterface $node */ foreach ($nodes as $node) { $node->setDeleted(false); } $this->eventDispatcher->dispatch(NodeEvents::NODE_RESTORE, new NodeEvent($node)); }
/** * @param NodeInterface $node * @param Constraint $constraint */ public function validate($node, Constraint $constraint) { if ($node->getNodeType() === NodeInterface::TYPE_DEFAULT && $node->getNodeId() !== NodeInterface::ROOT_NODE_ID) { $parentId = $node->getParentId(); $parent = $this->nodeRepository->findOneByNodeId($parentId); if (null === $parent || $parent->isDeleted()) { $nameParent = null === $parent ? '' : $parent->getName(); $this->context->buildViolation($constraint->message)->setParameters(array('%nodeparent%' => $nameParent))->addViolation(); } } }
/** * Checks if the passed value is valid. * * @param NodeInterface $value The value that should be validated * @param Constraint $constraint The constraint for the validation */ public function validate($value, Constraint $constraint) { $nodesSameRoute = $this->nodeRepository->findByParentAndRoutePattern($value->getParentId(), $value->getRoutePattern(), $value->getNodeId(), $value->getSiteId()); if (0 < count($nodesSameRoute)) { $nodesSameRoute = current($nodesSameRoute); $message = $constraint->message; if (true === $nodesSameRoute->isDeleted()) { $message = $constraint->messageWitNodeDeleted; } $this->context->buildViolation($message, array("%nodeName%" => $nodesSameRoute->getName()))->atPath('routePattern')->addViolation(); } }
/** * @param ObjectManager $manager * @param NodeInterface $node */ protected function generateRouteNode(ObjectManager $manager, $node) { $site = $this->getReference('site3'); foreach ($site->getAliases() as $key => $alias) { if ($alias->getLanguage() == $node->getLanguage()) { $route = new RouteDocument(); $route->setName($key . '_' . $node->getId()); $route->setHost($alias->getDomain()); $scheme = $alias->getScheme(); $route->setSchemes($scheme); $route->setLanguage($node->getLanguage()); $route->setNodeId($node->getNodeId()); $route->setSiteId($site->getSiteId()); $route->setAliasId($key); $route->setPattern($node->getRoutePattern()); $manager->persist($route); } } }
/** * @param array $orderedNode * @param NodeInterface $node */ public function orderNodeChildren($orderedNode, NodeInterface $node) { $nodeId = $node->getNodeId(); foreach ($orderedNode as $position => $childNodeId) { $siteId = $this->contextManager->getCurrentSiteId(); $children = $this->nodeRepository->findByNodeAndSite($childNodeId, $siteId); $path = $node->getPath() . '/' . $childNodeId; /** @var NodeInterface $child */ foreach ($children as $child) { $child->setOrder($position); $child->setParentId($nodeId); $child->setPath($path); } $event = new NodeEvent($child); $this->eventDispatcher->dispatch(NodeEvents::PATH_UPDATED, $event); } }
/** * @param NodeInterface $node */ public function generateRedirectionForNode(NodeInterface $node) { $siteId = $node->getSiteId(); $this->deleteRedirection($node->getNodeId(), $node->getLanguage(), $siteId); $nodes = $this->nodeRepository->findPublishedSortedByVersion($node->getNodeId(), $node->getLanguage(), $siteId); if (count($nodes) > 0) { $lastNode = array_shift($nodes); $routePatterns = array($this->completeRoutePattern($lastNode->getParentId(), $node->getRoutePattern(), $node->getLanguage())); foreach ($nodes as $otherNode) { $oldRoutePattern = $this->completeRoutePattern($otherNode->getParentId(), $otherNode->getRoutePattern(), $otherNode->getLanguage()); if (!in_array($oldRoutePattern, $routePatterns)) { $this->createRedirection($oldRoutePattern, $node->getNodeId(), $node->getLanguage()); array_push($routePatterns, $oldRoutePattern); } } } }
/** * @param NodeInterface $node * * @return FacadeInterface */ public function transformVersion($node) { $facade = $this->newFacade(); $facade->id = $node->getId(); $facade->nodeId = $node->getNodeId(); $facade->name = $node->getName(); $facade->version = $node->getVersion(); $facade->createdBy = $node->getCreatedBy(); $facade->updatedBy = $node->getUpdatedBy(); $facade->createdAt = $node->getCreatedAt(); $facade->updatedAt = $node->getUpdatedAt(); $facade->status = $this->getTransformer('status')->transform($node->getStatus()); return $facade; }
/** * @param string $message * @param NodeInterface $node */ protected function info($message, NodeInterface $node) { $this->logger->info($message, array('node_id' => $node->getNodeId(), 'node_version' => $node->getVersion(), 'node_language' => $node->getLanguage(), 'node_name' => $node->getName())); }
/** * @param FacadeInterface $facade * @param NodeInterface $node * @param AreaInterface $area * @param string $areaId */ protected function addLinksFromNode(FacadeInterface $facade, NodeInterface $node, AreaInterface $area, $areaId) { $facade->addLink('_block_list', $this->generateRoute('open_orchestra_api_block_list_with_transverse', array('language' => $node->getLanguage()))); $facade->addLink('_self_update_block_position', $this->generateRoute('open_orchestra_api_area_update_block_position', array('nodeId' => $node->getNodeId(), 'language' => $node->getLanguage(), 'version' => $node->getVersion(), 'siteId' => $node->getSiteId()))); }