本文整理汇总了PHP中TYPO3\Eel\FlowQuery\FlowQuery::parents方法的典型用法代码示例。如果您正苦于以下问题:PHP FlowQuery::parents方法的具体用法?PHP FlowQuery::parents怎么用?PHP FlowQuery::parents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\Eel\FlowQuery\FlowQuery
的用法示例。
在下文中一共展示了FlowQuery::parents方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parentsFollowedByFirstMatchesInnermostNodeOnRootline
/**
* @test
*/
public function parentsFollowedByFirstMatchesInnermostNodeOnRootline()
{
$teaserText = $this->node->getNode('teaser/dummy42');
$q = new FlowQuery(array($teaserText));
$actual = iterator_to_array($q->parents('[someSpecialProperty]')->first());
$expected = array($this->node->getNode('teaser'));
$this->assertTrue($expected === $actual);
}
示例2: render
/**
* @param NodeInterface $node A document node
* @return string
*/
public function render(NodeInterface $node)
{
$output = '/' . $node->getLabel();
$flowQuery = new FlowQuery(array($node));
$nodes = $flowQuery->parents('[instanceof TYPO3.Neos:Document]')->get();
/** @var NodeInterface $node */
foreach ($nodes as $node) {
$output = '/' . $node->getLabel() . $output;
}
return $output;
}
示例3: breadcrumbNodesForNode
/**
* @param NodeInterface $node
* @return array
*/
protected function breadcrumbNodesForNode(NodeInterface $node)
{
$documentNodes = [];
$flowQuery = new FlowQuery(array($node));
$nodes = array_reverse($flowQuery->parents('[instanceof TYPO3.Neos:Document]')->get());
/** @var NodeInterface $node */
foreach ($nodes as $documentNode) {
$documentNodes[] = $documentNode;
}
if ($node->getNodeType()->isOfType('TYPO3.Neos:Document')) {
$documentNodes[] = $node;
}
return $documentNodes;
}
示例4: render
/**
* @param NodeInterface $node A node
* @return array of document nodes
*/
public function render(NodeInterface $node)
{
$documentNodes = [];
$flowQuery = new FlowQuery(array($node));
$nodes = array_reverse($flowQuery->parents('[instanceof TYPO3.Neos:Document]')->get());
/** @var NodeInterface $node */
foreach ($nodes as $documentNode) {
$documentNodes[] = $documentNode;
}
if ($node->getNodeType()->isOfType('TYPO3.Neos:Document')) {
$documentNodes[] = $node;
}
$this->templateVariableContainer->add('documentNodes', $documentNodes);
$content = $this->renderChildren();
$this->templateVariableContainer->remove('documentNodes');
return $content;
}
开发者ID:johannessteu,项目名称:neos-development-collection,代码行数:21,代码来源:DocumentBreadcrumbPathViewHelper.php
示例5: evaluate
/**
* {@inheritdoc}
*
* @param FlowQuery $flowQuery the FlowQuery object
* @param array $arguments the arguments for this operation
* @return void
*/
public function evaluate(FlowQuery $flowQuery, array $arguments)
{
if (!isset($arguments[0]) || empty($arguments[0])) {
throw new \TYPO3\Eel\FlowQuery\FlowQueryException('closest() requires a filter argument', 1332492263);
}
$output = array();
foreach ($flowQuery->getContext() as $contextNode) {
$contextNodeQuery = new FlowQuery(array($contextNode));
$contextNodeQuery->pushOperation('first', array());
$contextNodeQuery->pushOperation('filter', $arguments);
$parentsQuery = new FlowQuery(array($contextNode));
$contextNodeQuery->pushOperation('add', array($parentsQuery->parents($arguments[0])->get()));
foreach ($contextNodeQuery as $result) {
$output[$result->getPath()] = $result;
}
}
$flowQuery->setContext(array_values($output));
}
示例6: 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);
}