/** * Vote for $action on $node not owned by $user * A user can act on someone else's node if he has the matching super role and the node is in his perimeter * * @param string $action * @param NodeInterface $node * @param UserInterface $user * * @return bool */ protected function voteForSomeoneElseSubject($action, $node, UserInterface $user) { $requiredRole = ContributionRoleInterface::NODE_CONTRIBUTOR; switch ($action) { case ContributionActionInterface::EDIT: $requiredRole = ContributionRoleInterface::NODE_SUPER_EDITOR; break; case ContributionActionInterface::DELETE: $requiredRole = ContributionRoleInterface::NODE_SUPER_SUPRESSOR; break; } return $user->hasRole($requiredRole) && $this->isSubjectInPerimeter($node->getPath(), $user, NodeInterface::ENTITY_TYPE); }
/** * @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 FacadeInterface $facade * @param NodeInterface $node * * @return FacadeInterface */ protected function addMainAttributes(FacadeInterface $facade, NodeInterface $node) { if ($site = $this->siteRepository->findOneBySiteId($node->getSiteId())) { $facade->templateSet = $site->getTemplateSet(); } $facade->id = $node->getId(); $facade->nodeId = $node->getNodeId(); $facade->name = $node->getName(); $facade->siteId = $node->getSiteId(); $facade->deleted = $node->isDeleted(); $facade->template = $node->getTemplate(); $facade->nodeType = $node->getNodeType(); $facade->parentId = $node->getParentId(); $facade->path = $node->getPath(); $facade->routePattern = $node->getRoutePattern(); $facade->language = $node->getLanguage(); $facade->metaDescription = $node->getMetaDescription(); $facade->metaIndex = $node->getMetaIndex(); $facade->metaFollow = $node->getMetaFollow(); $facade->theme = $node->getTheme(); $facade->themeSiteDefault = $node->hasDefaultSiteTheme(); $facade->version = $node->getVersion(); $facade->createdBy = $node->getCreatedBy(); $facade->updatedBy = $node->getUpdatedBy(); $facade->createdAt = $node->getCreatedAt(); $facade->updatedAt = $node->getUpdatedAt(); $facade->addRight('can_read', $this->authorizationChecker->isGranted(ContributionActionInterface::READ, $node)); return $facade; }