private function setSlugWhenEmpty(NodeTranslation $nodeTranslation, EntityManager $em)
 {
     $publicNode = $nodeTranslation->getRef($em);
     /** Do nothing for StructureNode objects, skip */
     if ($publicNode instanceof HasNodeInterface && $publicNode->isStructureNode()) {
         return;
     }
     /**
      * If no slug is set and no structure node, apply title as slug
      */
     if ($nodeTranslation->getSlug() === null && $nodeTranslation->getNode()->getParent() !== null) {
         $nodeTranslation->setSlug($this->slugifier->slugify($nodeTranslation->getTitle()));
     }
 }
 /**
  * Create a search document for a page
  *
  * @param NodeTranslation  $nodeTranslation
  * @param Node             $node
  * @param NodeVersion      $publicNodeVersion
  * @param HasNodeInterface $page
  */
 protected function addPageToIndex(NodeTranslation $nodeTranslation, Node $node, NodeVersion $publicNodeVersion, HasNodeInterface $page)
 {
     $rootNode = $this->currentTopNode;
     if (!$rootNode) {
         // Fetch main parent of current node...
         $rootNode = $this->em->getRepository('KunstmaanNodeBundle:Node')->getRootNodeFor($node, $nodeTranslation->getLang());
     }
     $doc = array('root_id' => $rootNode->getId(), 'node_id' => $node->getId(), 'node_translation_id' => $nodeTranslation->getId(), 'node_version_id' => $publicNodeVersion->getId(), 'title' => $nodeTranslation->getTitle(), 'lang' => $nodeTranslation->getLang(), 'slug' => $nodeTranslation->getFullSlug(), 'page_class' => ClassLookup::getClass($page), 'created' => $this->getUTCDateTime($nodeTranslation->getCreated())->format(\DateTime::ISO8601), 'updated' => $this->getUTCDateTime($nodeTranslation->getUpdated())->format(\DateTime::ISO8601));
     if ($this->logger) {
         $this->logger->info('Indexing document : ' . implode(', ', $doc));
     }
     // Permissions
     $this->addPermissions($node, $doc);
     // Search type
     $this->addSearchType($page, $doc);
     // Analyzer field
     $this->addAnalyzer($nodeTranslation, $doc);
     // Parent and Ancestors
     $this->addParentAndAncestors($node, $doc);
     // Content
     $this->addPageContent($nodeTranslation, $page, $doc);
     // Add document to index
     $uid = 'nodetranslation_' . $nodeTranslation->getId();
     $this->addBoost($node, $page, $doc);
     $this->addCustomData($page, $doc);
     $this->documents[] = $this->searchProvider->createDocument($uid, $doc, $this->indexName, $this->indexType . '_' . $nodeTranslation->getLang());
 }
 /**
  * @covers Kunstmaan\NodeBundle\Entity\NodeTranslation::setTitle
  * @covers Kunstmaan\NodeBundle\Entity\NodeTranslation::getTitle
  */
 public function testSetGetTitle()
 {
     $this->object->setTitle('A node translation title');
     $this->assertEquals('A node translation title', $this->object->getTitle());
 }
 private function nodeTranslationToCategory(NodeTranslation $nt)
 {
     return new Category($nt->getTitle(), $nt->getNode()->getId(), $nt->getUrl());
 }