/**
  * 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
  * @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 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;
 }