本文整理汇总了PHP中TYPO3\Eel\FlowQuery\FlowQuery::count方法的典型用法代码示例。如果您正苦于以下问题:PHP FlowQuery::count方法的具体用法?PHP FlowQuery::count怎么用?PHP FlowQuery::count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\Eel\FlowQuery\FlowQuery
的用法示例。
在下文中一共展示了FlowQuery::count方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: evaluate
/**
* {@inheritdoc}
*
* @param FlowQuery $flowQuery
* @param array $arguments
* @return void
*/
public function evaluate(FlowQuery $flowQuery, array $arguments)
{
$subject = $arguments[0];
if (!isset($subject) || empty($subject)) {
$flowQuery->setContext(array());
return;
}
$filteredContext = array();
$context = $flowQuery->getContext();
if (is_string($subject)) {
foreach ($context as $contextElement) {
$contextElementQuery = new FlowQuery(array($contextElement));
$contextElementQuery->pushOperation('children', $arguments);
if ($contextElementQuery->count() > 0) {
$filteredContext[] = $contextElement;
}
}
} else {
if ($subject instanceof \TYPO3\Eel\FlowQuery\FlowQuery) {
$elements = $subject->get();
} elseif ($subject instanceof \Traversable) {
$elements = iterator_to_array($subject);
} elseif (is_object($subject)) {
$elements = array($subject);
} elseif (is_array($subject)) {
$elements = $subject;
} else {
throw new \TYPO3\Eel\FlowQuery\FizzleException('supplied argument for has operation not supported', 1332489625);
}
foreach ($elements as $element) {
if ($element instanceof NodeInterface) {
$parentsQuery = new FlowQuery(array($element));
/** @var NodeInterface $parent */
foreach ($parentsQuery->parents(array())->get() as $parent) {
/** @var NodeInterface $contextElement */
foreach ($context as $contextElement) {
if ($contextElement->getIdentifier() === $parent->getIdentifier()) {
$filteredContext[] = $contextElement;
}
}
}
}
}
$filteredContext = array_unique($filteredContext);
}
$flowQuery->setContext($filteredContext);
}