Created
August 15, 2012 14:36
-
-
Save aertmann/3360651 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Finds the nearest parent folder node of the provided node by looping recursively trough | |
* the node's parent nodes and checking if they are a sub content type of TYPO3.TYPO3CR:Folder | |
* | |
* @param \TYPO3\TYPO3CR\Domain\Model\NodeInterface $node | |
* @return \TYPO3\TYPO3CR\Domain\Model\NodeInterface|NULL | |
*/ | |
protected function findNextParentFolderNode(\TYPO3\TYPO3CR\Domain\Model\NodeInterface $node) { | |
$folderTypes = $this->contentTypeManager->getSubContentTypes('TYPO3.TYPO3CR:Folder'); | |
while ($node) { | |
if (array_key_exists($node->getContentType(), $folderTypes)) { | |
return $node; | |
} | |
$node = $node->getParent(); | |
} | |
return NULL; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment