/**
  * @param NodeTranslation $nodeTranslation
  *
  * @throws AccessDeniedException
  */
 public function unPublish(NodeTranslation $nodeTranslation)
 {
     if (false === $this->authorizationChecker->isGranted(PermissionMap::PERMISSION_UNPUBLISH, $nodeTranslation->getNode())) {
         throw new AccessDeniedException();
     }
     $node = $nodeTranslation->getNode();
     $nodeVersion = $nodeTranslation->getPublicNodeVersion();
     $page = $nodeVersion->getRef($this->em);
     $this->eventDispatcher->dispatch(Events::PRE_UNPUBLISH, new NodeEvent($node, $nodeTranslation, $nodeVersion, $page));
     $nodeTranslation->setOnline(false);
     $this->em->persist($nodeTranslation);
     $this->em->flush();
     // Remove scheduled task
     $this->unSchedulePublish($nodeTranslation);
     $this->eventDispatcher->dispatch(Events::POST_UNPUBLISH, new NodeEvent($node, $nodeTranslation, $nodeVersion, $page));
 }
 /**
  * @covers Kunstmaan\NodeBundle\Entity\NodeTranslation::setOnline
  * @covers Kunstmaan\NodeBundle\Entity\NodeTranslation::isOnline
  */
 public function testSetIsOnline()
 {
     $this->object->setOnline(true);
     $this->assertTrue($this->object->isOnline());
 }
 /**
  * @covers Kunstmaan\NodeBundle\Entity\Node::addNodeTranslation
  * @covers Kunstmaan\NodeBundle\Entity\Node::getNodeTranslation
  */
 public function testGetNodeTranslation()
 {
     $translation1 = new NodeTranslation();
     $translation1->setLang('nl');
     $translation1->setOnline(true);
     $this->object->addNodeTranslation($translation1);
     $translation2 = new NodeTranslation();
     $translation2->setLang('fr');
     $translation2->setOnline(true);
     $this->object->addNodeTranslation($translation2);
     $this->assertEquals($translation1, $this->object->getNodeTranslation('nl'));
     $this->assertEquals($translation2, $this->object->getNodeTranslation('fr'));
     $this->assertNotEquals($translation1, $this->object->getNodeTranslation('fr'));
     $this->assertNotEquals($translation2, $this->object->getNodeTranslation('nl'));
     $this->assertNull($this->object->getNodeTranslation('en'));
 }