コード例 #1
0
 /**
  * @covers Kunstmaan\NodeBundle\Entity\Node::isHiddenFromNav
  * @covers Kunstmaan\NodeBundle\Entity\Node::getHiddenFromNav
  * @covers Kunstmaan\NodeBundle\Entity\Node::setHiddenFromNav
  */
 public function testIsGetSetHiddenFromNav()
 {
     $this->assertFalse($this->object->getHiddenFromNav());
     $this->object->setHiddenFromNav(true);
     $this->assertTrue($this->object->isHiddenFromNav());
     $this->assertTrue($this->object->getHiddenFromNav());
 }
コード例 #2
0
 private function createRootNode($page, $language, $internalName, $fixtureParams)
 {
     $rootNode = new Node();
     $rootNode->setRef($page);
     $rootNode->setDeleted(false);
     $rootNode->setInternalName($internalName);
     $rootNode->setHiddenFromNav(isset($fixtureParams['hidden_from_nav']) ? $fixtureParams['hidden_from_nav'] : false);
     $parent = $this->getParentNode($fixtureParams, $language);
     if ($parent instanceof Node) {
         $rootNode->setParent($parent);
     }
     return $rootNode;
 }
コード例 #3
0
 /**
  * @param HasNodeInterface $hasNode      The object to link to
  * @param string           $lang         The locale
  * @param BaseUser         $owner        The user
  * @param string           $internalName The internal name (may be null)
  *
  * @throws \InvalidArgumentException
  *
  * @return Node
  */
 public function createNodeFor(HasNodeInterface $hasNode, $lang, BaseUser $owner, $internalName = null)
 {
     $em = $this->getEntityManager();
     $node = new Node();
     $node->setRef($hasNode);
     if (!$hasNode->getId() > 0) {
         throw new \InvalidArgumentException("the entity of class " . $node->getRefEntityName() . " has no id, maybe you forgot to flush first");
     }
     $node->setDeleted(false);
     $node->setInternalName($internalName);
     $parent = $hasNode->getParent();
     if ($parent) {
         /* @var NodeVersion $parentNodeVersion */
         $parentNodeVersion = $em->getRepository('KunstmaanNodeBundle:NodeVersion')->findOneBy(array('refId' => $parent->getId(), 'refEntityName' => ClassLookup::getClass($parent)));
         if ($parentNodeVersion) {
             $node->setParent($parentNodeVersion->getNodeTranslation()->getNode());
         }
     }
     if ($hasNode instanceof HiddenFromNavInterface) {
         $node->setHiddenFromNav($hasNode->isHiddenFromNav());
     }
     $em->persist($node);
     $em->flush();
     $em->refresh($node);
     $em->getRepository('KunstmaanNodeBundle:NodeTranslation')->createNodeTranslationFor($hasNode, $lang, $node, $owner);
     return $node;
 }
コード例 #4
0
 private function createRootNode($page, $language, $internalName, $fixtureParams)
 {
     $rootNode = new Node();
     $rootNode->setRef($page);
     $rootNode->setDeleted(false);
     $rootNode->setInternalName($internalName);
     $rootNode->setHiddenFromNav(isset($fixtureParams['hidden_from_nav']) ? $fixtureParams['hidden_from_nav'] : false);
     $parent = $this->getParentNode($fixtureParams, $language);
     if ($parent instanceof Node) {
         $rootNode->setParent($parent);
         if (!$this->canHaveChild($parent->getRefEntityName(), get_class($page))) {
             throw new \Exception(sprintf('A %s can\'t have a %s as child. Forgot to add in allowed_children or getPossibleChildTypes?', $parent->getRefEntityName(), get_class($page)));
         }
     }
     return $rootNode;
 }