Skip to content

Instantly share code, notes, and snippets.

@aertmann
Created August 15, 2012 14:36
Show Gist options
  • Save aertmann/3360651 to your computer and use it in GitHub Desktop.
Save aertmann/3360651 to your computer and use it in GitHub Desktop.
/**
* 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