Created
November 25, 2014 08:53
-
-
Save johannessteu/d573ce2d7e64754f8eb0 to your computer and use it in GitHub Desktop.
Use EelExpressions to filter Nodes in PHP
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
/** | |
* @var SiteRepository | |
* @Flow\Inject | |
*/ | |
protected $siteRepository; | |
/** | |
* @var \TYPO3\Neos\Domain\Service\ContentContextFactory | |
* @Flow\Inject | |
*/ | |
protected $contentContextFactory; | |
/** ---------------------------------------- */ | |
/** @var \TYPO3\Neos\Domain\Model\Site $site */ | |
$site = $this->siteRepository->findOnline()->getFirst(); | |
/** @var ContentContext $context */ | |
$context = $this->contentContextFactory->create(array("currentSite" => $site)); | |
/* Will be an instance of \TYPO3\Eel\CompilingEvaluator */ | |
$eelEvauator = $this->objectManager->get('TYPO3\Eel\EelEvaluatorInterface'); | |
/** | |
* Don't forget to provide an array with all context variables like "site" in | |
* this example | |
* | |
* @var \TYPO3\Eel\FlowQuery\FlowQuery $nodes | |
*/ | |
$nodeCount = \TYPO3\Eel\Utility::evaluateEelExpression('${q(site).children("main").count()}', $eelEvauator, array("site" => $context->getCurrentSiteNode())); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment