Skip to content

Commit

Permalink
Merge pull request #559 from krispypen/feature/hiddenfromnav_interface
Browse files Browse the repository at this point in the history
[NodeBundle] Possible to create a page type which is default hidden from navigation
  • Loading branch information
Roderik van der Veer committed Jul 16, 2015
2 parents b1398bf + 2e05443 commit 0aa94c3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/Kunstmaan/NodeBundle/Helper/HiddenFromNavInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace Kunstmaan\NodeBundle\Helper;

/**
* Implement this interface to give you control over the navigation behavior of this page
*/
interface HiddenFromNavInterface
{
/**
* Returns true when the page is to be hidden from the navigation
*
* @return bool
*/
public function isHiddenFromNav();

}
4 changes: 4 additions & 0 deletions src/Kunstmaan/NodeBundle/Repository/NodeRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Kunstmaan\NodeBundle\Entity\NodeTranslation;
use Kunstmaan\NodeBundle\Entity\NodeVersion;
use Kunstmaan\UtilitiesBundle\Helper\ClassLookup;
use Kunstmaan\NodeBundle\Helper\HiddenFromNavInterface;

/**
* NodeRepository
Expand Down Expand Up @@ -166,6 +167,9 @@ public function createNodeFor(HasNodeInterface $hasNode, $lang, BaseUser $owner,
$node->setParent($parentNodeVersion->getNodeTranslation()->getNode());
}
}
if ($hasNode instanceof HiddenFromNavInterface) {
$node->setHiddenFromNav($hasNode->isHiddenFromNav());
}
$em->persist($node);
$em->flush();
$em->refresh($node);
Expand Down

0 comments on commit 0aa94c3

Please sign in to comment.