getClassMetadata(Node::class)); } public function urlExists($url, Node $node) { $query = $this->createQueryBuilder('n') ->where('n.url = :url') ->setParameter(':url', $url) ; if ($node->getId()) { $query ->andWhere('n.id != :id') ->setParameter(':id', $node->getId()) ; } return $query->getQuery() ->setMaxResults(1) ->getOneOrNullResult() ; } }