/**
  * {@inheritdoc}
  *
  * @param FlowQuery $flowQuery the FlowQuery object
  * @param array $arguments the arguments for this operation.
  * First argument is property to filter by, must be of reference of references type.
  * Second is object to filter by, must be Node.
  * @return mixed
  */
 public function evaluate(FlowQuery $flowQuery, array $arguments)
 {
     if (!isset($arguments[0]) || empty($arguments[0])) {
         throw new \TYPO3\Eel\FlowQuery\FlowQueryException('FilterByReference() needs reference property name by which nodes should be filtered', 1332492263);
     } elseif (!isset($arguments[1]) || empty($arguments[1])) {
         throw new \TYPO3\Eel\FlowQuery\FlowQueryException('FilterByReference() needs object by which nodes should be filtered', 1332493263);
     } else {
         $nodes = $flowQuery->getContext();
         $filterByPropertyPath = $arguments[0];
         /** @var Node $object  */
         $object = $arguments[1];
         $filteredNodes = array();
         /** @var Node $node  */
         foreach ($nodes as $node) {
             $propertyValue = $node->getProperty($filterByPropertyPath);
             if (is_array($propertyValue)) {
                 if (in_array($object, $propertyValue)) {
                     $filteredNodes[] = $node;
                 }
             } else {
                 if ($object == $propertyValue) {
                     $filteredNodes[] = $node;
                 }
             }
         }
         $flowQuery->setContext($filteredNodes);
     }
 }
 /**
  * Tests on a tree:
  *
  * a
  *   a1
  *   a2
  * b (TestingNodeType)
  *   b1 (TestingNodeType)
  *     b1a
  *   b2
  *   b3 (TestingNodeTypeWithSubnodes)
  *     b3a (TestingNodeType)
  *     b3b
  *
  * @test
  * @dataProvider closestOperationDataProvider
  */
 public function closestOperationTests($currentNodePath, $nodeTypeFilter, $expectedNodePath)
 {
     $nodeTypeManager = $this->objectManager->get('TYPO3\\TYPO3CR\\Domain\\Service\\NodeTypeManager');
     $testNodeType1 = $nodeTypeManager->getNodeType('TYPO3.TYPO3CR.Testing:NodeType');
     $testNodeType2 = $nodeTypeManager->getNodeType('TYPO3.TYPO3CR.Testing:NodeTypeWithSubnodes');
     $rootNode = $this->node->getNode('/');
     $nodeA = $rootNode->createNode('a');
     $nodeA->createNode('a1');
     $nodeA->createNode('a2');
     $nodeB = $rootNode->createNode('b', $testNodeType1);
     $nodeB1 = $nodeB->createNode('b1', $testNodeType1);
     $nodeB1->createNode('b1a');
     $nodeB->createNode('b2');
     $nodeB3 = $nodeB->createNode('b3', $testNodeType2);
     $nodeB3->createNode('b3a', $testNodeType1);
     $nodeB3->createNode('b3b');
     $currentNode = $rootNode->getNode($currentNodePath);
     $q = new FlowQuery(array($currentNode));
     $actualNode = $q->closest($nodeTypeFilter)->get(0);
     if ($expectedNodePath === null) {
         if ($actualNode !== null) {
             $this->fail('Expected resulting node to be NULL');
         }
         $this->assertNull($actualNode);
     } else {
         $this->assertSame($expectedNodePath, $actualNode->getPath());
     }
 }
 /**
  * @Flow\Before("method(TYPO3\Neos\Controller\Backend\ContentController->uploadAssetAction())")
  * @param JoinPointInterface $joinPoint The current join point
  * @return void
  */
 public function rewriteSiteAssetCollection(JoinPointInterface $joinPoint)
 {
     if ($this->lookupNodeFilter === NULL || $this->lookupPropertyName === NULL) {
         return;
     }
     /** @var ContentController $contentController */
     $contentController = $joinPoint->getProxy();
     /** @var ActionRequest $actionRequest */
     $actionRequest = ObjectAccess::getProperty($contentController, 'request', TRUE);
     $nodeContextPath = $actionRequest->getInternalArgument('__node');
     if ($nodeContextPath === NULL) {
         return;
     }
     $node = $this->propertyMapper->convert($nodeContextPath, NodeInterface::class);
     $flowQuery = new FlowQuery(array($node));
     /** @var NodeInterface $documentNode */
     $documentNode = $flowQuery->closest($this->lookupNodeFilter)->get(0);
     if (!$documentNode->hasProperty($this->lookupPropertyName)) {
         return;
     }
     /** @var AssetCollection $assetCollection */
     $assetCollection = $this->assetCollectionRepository->findByIdentifier($documentNode->getProperty($this->lookupPropertyName));
     if ($assetCollection === NULL) {
         return;
     }
     /** @var Asset $asset */
     $asset = $joinPoint->getMethodArgument('asset');
     $assetCollection->addAsset($asset);
     $this->assetCollectionRepository->update($assetCollection);
 }
 /**
  * Tests on a tree:
  *
  * a
  *   a1
  * b
  *   b1 (TestingNodeType)
  *     b1a
  * c
  *
  * @test
  * @dataProvider hasOperationDataProvider()
  */
 public function hasOperationTests(array $currentNodePaths, $subject, array $expectedNodePaths)
 {
     $nodeTypeManager = $this->objectManager->get('TYPO3\\TYPO3CR\\Domain\\Service\\NodeTypeManager');
     $testNodeType1 = $nodeTypeManager->getNodeType('TYPO3.TYPO3CR.Testing:NodeType');
     $rootNode = $this->node->getNode('/');
     $nodeA = $rootNode->createNode('a');
     $nodeA->createNode('a1');
     $nodeB = $rootNode->createNode('b');
     $nodeB1 = $nodeB->createNode('b1', $testNodeType1);
     $nodeB1->createNode('b1a');
     $rootNode->createNode('c');
     $currentNodes = array();
     foreach ($currentNodePaths as $currentNodePath) {
         $currentNodes[] = $rootNode->getNode($currentNodePath);
     }
     if (is_array($subject)) {
         $subjectNodes = array();
         foreach ($subject as $subjectNodePath) {
             $subjectNodes[] = $rootNode->getNode($subjectNodePath);
         }
         $subject = $subjectNodes;
     }
     $q = new FlowQuery($currentNodes);
     $result = $q->has($subject)->get();
     if ($expectedNodePaths === array()) {
         $this->assertEmpty($result);
     } else {
         foreach ($expectedNodePaths as $expectedNodePath) {
             $expectedNode = $rootNode->getNode($expectedNodePath);
             if (!in_array($expectedNode, $result)) {
                 $this->fail(sprintf('Expected result to contain node "%s"', $expectedNodePath));
             }
         }
     }
 }
 /**
  * {@inheritdoc}
  *
  * @param FlowQuery $flowQuery the FlowQuery object
  * @param array $arguments the arguments for this operation
  * @return void
  */
 public function evaluate(FlowQuery $flowQuery, array $arguments)
 {
     $output = array();
     $outputNodePaths = array();
     $until = array();
     foreach ($flowQuery->getContext() as $contextNode) {
         $prevNodes = $this->getPrevForNode($contextNode);
         if (isset($arguments[0]) && !empty($arguments[0])) {
             $untilQuery = new FlowQuery($prevNodes);
             $untilQuery->pushOperation('filter', array($arguments[0]));
             $until = $untilQuery->get();
         }
         if (isset($until) && !empty($until)) {
             $until = end($until);
             $prevNodes = $this->getNodesUntil($prevNodes, $until);
         }
         if (is_array($prevNodes)) {
             foreach ($prevNodes as $prevNode) {
                 if ($prevNode !== NULL && !isset($outputNodePaths[$prevNode->getPath()])) {
                     $outputNodePaths[$prevNode->getPath()] = TRUE;
                     $output[] = $prevNode;
                 }
             }
         }
     }
     $flowQuery->setContext($output);
     if (isset($arguments[1]) && !empty($arguments[1])) {
         $flowQuery->pushOperation('filter', array($arguments[1]));
     }
 }
 /**
  * {@inheritdoc}
  *
  * @param FlowQuery $flowQuery the FlowQuery object
  * @param array $arguments the arguments for this operation
  * @return void
  */
 public function evaluate(FlowQuery $flowQuery, array $arguments)
 {
     $output = array();
     $outputNodePaths = array();
     foreach ($flowQuery->getContext() as $contextNode) {
         $siteNode = $contextNode->getContext()->getCurrentSiteNode();
         $parentNodes = $this->getParents($contextNode, $siteNode);
         if (isset($arguments[0]) && !empty($arguments[0] && isset($parentNodes[0]))) {
             $untilQuery = new FlowQuery(array($parentNodes[0]));
             $untilQuery->pushOperation('closest', array($arguments[0]));
             $until = $untilQuery->get();
         }
         if (isset($until) && is_array($until) && !empty($until) && isset($until[0])) {
             $parentNodes = $this->getNodesUntil($parentNodes, $until[0]);
         }
         if (is_array($parentNodes)) {
             foreach ($parentNodes as $parentNode) {
                 if ($parentNode !== null && !isset($outputNodePaths[$parentNode->getPath()])) {
                     $outputNodePaths[$parentNode->getPath()] = true;
                     $output[] = $parentNode;
                 }
             }
         }
     }
     $flowQuery->setContext($output);
     if (isset($arguments[1]) && !empty($arguments[1])) {
         $flowQuery->pushOperation('filter', $arguments[1]);
     }
 }
 /**
  * {@inheritdoc}
  *
  * @param FlowQuery $flowQuery the FlowQuery object
  * @param array $arguments the arguments for this operation
  * @return mixed
  */
 public function evaluate(FlowQuery $flowQuery, array $arguments)
 {
     if (!isset($arguments[0]) || empty($arguments[0])) {
         throw new \TYPO3\Eel\FlowQuery\FlowQueryException('sort() needs property name by which nodes should be sorted', 1332492263);
     } else {
         $nodes = $flowQuery->getContext();
         $sortByPropertyPath = $arguments[0];
         $sortOrder = 'DESC';
         if (isset($arguments[1]) && !empty($arguments[1]) && in_array($arguments[1], array('ASC', 'DESC'))) {
             $sortOrder = $arguments[1];
         }
         $sortedNodes = array();
         $sortSequence = array();
         $nodesByIdentifier = array();
         /** @var Node $node  */
         foreach ($nodes as $node) {
             $propertyValue = $node->getProperty($sortByPropertyPath);
             // \TYPO3\Flow\var_dump($propertyValue);
             if ($propertyValue instanceof \DateTime) {
                 $propertyValue = $propertyValue->getTimestamp();
             }
             $sortSequence[$node->getIdentifier()] = $propertyValue;
             $nodesByIdentifier[$node->getIdentifier()] = $node;
         }
         if ($sortOrder === 'DESC') {
             arsort($sortSequence);
         } else {
             asort($sortSequence);
         }
         foreach ($sortSequence as $nodeIdentifier => $value) {
             $sortedNodes[] = $nodesByIdentifier[$nodeIdentifier];
         }
         $flowQuery->setContext($sortedNodes);
     }
 }
 /**
  * {@inheritdoc}
  *
  * @param FlowQuery $flowQuery the FlowQuery object
  * @param array $arguments the arguments for this operation.
  * First argument is property to filter by, must be DateTime.
  * Second is Date operand, must be DateTime object.
  * And third is a compare operator: '<' or '>', '>' by default
  * @return mixed
  */
 public function evaluate(FlowQuery $flowQuery, array $arguments)
 {
     if (!isset($arguments[0]) || empty($arguments[0])) {
         throw new \TYPO3\Eel\FlowQuery\FlowQueryException('filterByDate() needs property name by which nodes should be filtered', 1332492263);
     } elseif (!isset($arguments[1]) || empty($arguments[1])) {
         throw new \TYPO3\Eel\FlowQuery\FlowQueryException('filterByDate() needs date value by which nodes should be filtered', 1332493263);
     } else {
         $nodes = $flowQuery->getContext();
         $filterByPropertyPath = $arguments[0];
         $date = $arguments[1];
         $compareOperator = '>';
         if (isset($arguments[2]) && !empty($arguments[2]) && in_array($arguments[2], array('<', '>'))) {
             $compareOperator = $arguments[2];
         }
         $filteredNodes = array();
         /** @var Node $node  */
         foreach ($nodes as $node) {
             $propertyValue = $node->getProperty($filterByPropertyPath);
             if ($compareOperator == '>') {
                 if ($propertyValue > $date) {
                     $filteredNodes[] = $node;
                 }
             }
             if ($compareOperator == '<') {
                 if ($propertyValue < $date) {
                     $filteredNodes[] = $node;
                 }
             }
         }
         $flowQuery->setContext($filteredNodes);
     }
 }
 /**
  * @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);
 }
 /**
  * Helper method to retrieve the closest document for a node
  *
  * @param NodeInterface $node
  * @return NodeInterface
  */
 public function getClosestDocument(NodeInterface $node)
 {
     if ($node->getNodeType()->isOfType('TYPO3.Neos:Document')) {
         return $node;
     }
     $flowQuery = new FlowQuery(array($node));
     return $flowQuery->closest('[instanceof TYPO3.Neos:Document]')->get(0);
 }
 /**
  * {@inheritdoc}
  *
  * @param \TYPO3\Eel\FlowQuery\FlowQuery $flowQuery the FlowQuery object
  * @param array $arguments Ignored for this operation
  * @return void
  */
 public function evaluate(\TYPO3\Eel\FlowQuery\FlowQuery $flowQuery, array $arguments)
 {
     $context = $flowQuery->getContext();
     if (isset($context[0])) {
         $flowQuery->setContext(array($context[0]));
     } else {
         $flowQuery->setContext(array());
     }
 }
 /**
  * {@inheritdoc}
  *
  * @param \TYPO3\Eel\FlowQuery\FlowQuery $flowQuery the FlowQuery object
  * @param array $arguments Ignored for this operation
  * @return void
  */
 public function evaluate(\TYPO3\Eel\FlowQuery\FlowQuery $flowQuery, array $arguments)
 {
     $context = $flowQuery->getContext();
     if (count($context) > 0) {
         $flowQuery->setContext(array(end($context)));
     } else {
         $flowQuery->setContext(array());
     }
 }
 /**
  * {@inheritdoc}
  *
  * @param \TYPO3\Eel\FlowQuery\FlowQuery $flowQuery the FlowQuery object
  * @param array $arguments filter arguments for this operation
  * @return void|integer with the number of elements
  */
 public function evaluate(\TYPO3\Eel\FlowQuery\FlowQuery $flowQuery, array $arguments)
 {
     if (count($arguments) == 0) {
         return count($flowQuery->getContext());
     } else {
         $flowQuery->pushOperation('count', array());
         $flowQuery->pushOperation('filter', $arguments);
     }
 }
 /**
  * {@inheritdoc}
  *
  * @param FlowQuery $flowQuery the FlowQuery object
  * @param array $arguments A mandatory start and optional end index in the context, negative indices indicate an offset from the start or end respectively
  * @return void
  */
 public function evaluate(FlowQuery $flowQuery, array $arguments)
 {
     $context = $flowQuery->getContext();
     if (isset($arguments[0]) && isset($arguments[1])) {
         $context = array_slice($context, (int) $arguments[0], (int) $arguments[1] - (int) $arguments[0]);
     } elseif (isset($arguments[0])) {
         $context = array_slice($context, (int) $arguments[0]);
     }
     $flowQuery->setContext($context);
 }
 /**
  * @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;
 }
 /**
  * {@inheritdoc}
  *
  * @param FlowQuery $flowQuery the FlowQuery object
  * @param array $arguments A mandatory start and optional end index in the context, negative indices indicate an offset from the start or end respectively
  * @return void
  */
 public function evaluate(FlowQuery $flowQuery, array $arguments)
 {
     $context = $flowQuery->getContext();
     if ($context instanceof \Iterator) {
         $context = iterator_to_array($context);
     }
     if (isset($arguments[0]) && isset($arguments[1])) {
         $context = array_slice($context, (int) $arguments[0], (int) $arguments[1] - (int) $arguments[0]);
     } elseif (isset($arguments[0])) {
         $context = array_slice($context, (int) $arguments[0]);
     }
     $flowQuery->setContext($context);
 }
 /**
  * Evaluate the property name filter by traversing to the child object. We only support
  * nested objects right now
  *
  * @param \TYPO3\Eel\FlowQuery\FlowQuery $query
  * @param string $propertyNameFilter
  * @return void
  */
 protected function evaluatePropertyNameFilter(\TYPO3\Eel\FlowQuery\FlowQuery $query, $propertyNameFilter)
 {
     $resultObjects = array();
     $resultObjectHashes = array();
     foreach ($query->getContext() as $element) {
         $subProperty = \TYPO3\Flow\Reflection\ObjectAccess::getPropertyPath($element, $propertyNameFilter);
         if (is_object($subProperty) && !isset($resultObjectHashes[spl_object_hash($subProperty)])) {
             $resultObjectHashes[spl_object_hash($subProperty)] = TRUE;
             $resultObjects[] = $subProperty;
         }
     }
     $query->setContext($resultObjects);
 }
 /**
  * {@inheritdoc}
  *
  * @param \TYPO3\Eel\FlowQuery\FlowQuery $flowQuery the FlowQuery object
  * @param array $arguments the elements to add (as array in index 0)
  * @return void
  */
 public function evaluate(\TYPO3\Eel\FlowQuery\FlowQuery $flowQuery, array $arguments)
 {
     $output = array();
     foreach ($flowQuery->getContext() as $element) {
         $output[] = $element;
     }
     if (isset($arguments[0])) {
         foreach ($arguments[0] as $element) {
             $output[] = $element;
         }
     }
     $flowQuery->setContext($output);
 }
 /**
  * {@inheritdoc}
  *
  * @param \TYPO3\Eel\FlowQuery\FlowQuery $flowQuery the FlowQuery object
  * @param array $arguments the context index to fetch from
  * @return mixed
  */
 public function evaluate(\TYPO3\Eel\FlowQuery\FlowQuery $flowQuery, array $arguments)
 {
     $context = $flowQuery->getContext();
     if (isset($arguments[0])) {
         $index = $arguments[0];
         if (isset($context[$index])) {
             return $context[$index];
         } else {
             return null;
         }
     } else {
         return $context;
     }
 }
 /**
  * {@inheritdoc}
  *
  * @param \TYPO3\Eel\FlowQuery\FlowQuery $flowQuery the FlowQuery object
  * @param array $arguments the property path to use (in index 0)
  * @return mixed
  */
 public function evaluate(\TYPO3\Eel\FlowQuery\FlowQuery $flowQuery, array $arguments)
 {
     if (!isset($arguments[0]) || empty($arguments[0])) {
         throw new \TYPO3\Eel\FlowQuery\FlowQueryException('property() must be given an attribute name when used on objects, fetching all attributes is not supported.', 1332492263);
     } else {
         $context = $flowQuery->getContext();
         if (!isset($context[0])) {
             return null;
         }
         $element = $context[0];
         $propertyPath = $arguments[0];
         return \TYPO3\Flow\Reflection\ObjectAccess::getPropertyPath($element, $propertyPath);
     }
 }
 /**
  * @return string
  */
 public final function getList()
 {
     $context = $this->contextFactory->create(['workspaceName' => 'live']);
     $flowQuery = new FlowQuery([$context->getRootNode()]);
     $events = $flowQuery->find('[instanceof Nieuwenhuizen.BuJitsuDo:Article]')->get();
     $result['articles'] = [];
     usort($events, function (NodeInterface $a, NodeInterface $b) {
         return $this->sortNodesSelection($a, $b, 'publicationDate', false);
     });
     foreach ($events as $event) {
         $result['articles'][] = $this->buildSingleItemJson($event);
     }
     return $result;
 }
 /**
  * @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;
 }
 /**
  * @return array
  */
 public function buildItems()
 {
     $output = array();
     $dimension = $this->getDimension();
     foreach ($this->getPresetsInCorrectOrder() as $presetName => $presetConfiguration) {
         $q = new FlowQuery(array($this->currentNode));
         $nodeInOtherDimension = $q->context(array('dimensions' => array($dimension => $presetConfiguration['values']), 'targetDimensions' => array($dimension => reset($presetConfiguration['values']))))->get(0);
         if ($nodeInOtherDimension !== NULL && $this->isNodeHidden($nodeInOtherDimension)) {
             $nodeInOtherDimension = NULL;
         }
         $item = array('node' => $nodeInOtherDimension, 'state' => $this->calculateItemState($nodeInOtherDimension), 'label' => $presetConfiguration['label'], 'presetName' => $presetName, 'preset' => $presetConfiguration);
         $output[] = $item;
     }
     return $output;
 }
 /**
  * {@inheritdoc}
  *
  * @param FlowQuery $flowQuery the FlowQuery object
  * @param array $arguments the arguments for this operation
  * @return void
  */
 public function evaluate(FlowQuery $flowQuery, array $arguments)
 {
     $output = array();
     $outputNodePaths = array();
     foreach ($flowQuery->getContext() as $contextNode) {
         $prevNode = $this->getPrevForNode($contextNode);
         if ($prevNode !== NULL && !isset($outputNodePaths[$prevNode->getPath()])) {
             $outputNodePaths[$prevNode->getPath()] = TRUE;
             $output[] = $prevNode;
         }
     }
     $flowQuery->setContext($output);
     if (isset($arguments[0]) && !empty($arguments[0])) {
         $flowQuery->pushOperation('filter', $arguments);
     }
 }
 /**
  * {@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]) || !is_array($arguments[0])) {
         throw new \TYPO3\Eel\FlowQuery\FlowQueryException('context() requires an array argument of context properties', 1398030427);
     }
     $output = array();
     foreach ($flowQuery->getContext() as $contextNode) {
         $contextProperties = $contextNode->getContext()->getProperties();
         $modifiedContext = $this->contextFactory->create(array_merge($contextProperties, $arguments[0]));
         $nodeInModifiedContext = $modifiedContext->getNodeByIdentifier($contextNode->getIdentifier());
         if ($nodeInModifiedContext !== null) {
             $output[$nodeInModifiedContext->getPath()] = $nodeInModifiedContext;
         }
     }
     $flowQuery->setContext(array_values($output));
 }
 /**
  * @param array $nodes
  */
 public function assignNodes(array $nodes)
 {
     $data = array();
     foreach ($nodes as $node) {
         if ($node->getPath() !== '/') {
             $q = new FlowQuery(array($node));
             $closestDocumentNode = $q->closest('[instanceof TYPO3.Neos:Document]')->get(0);
             if ($closestDocumentNode !== NULL) {
                 $data[] = array('nodeContextPath' => $node->getContextPath(), 'documentNodeContextPath' => $closestDocumentNode->getContextPath());
             } else {
                 $this->systemLogger->log('You have a node that is no longer connected to a parent. Path: ' . $node->getPath() . ' (Identifier: ' . $node->getIdentifier() . ')');
             }
         }
     }
     $this->assign('value', array('data' => $data, 'success' => TRUE));
 }
 /**
  * {@inheritdoc}
  *
  * @param FlowQuery $flowQuery the FlowQuery object
  * @param array $arguments the arguments for this operation
  * @return void
  */
 public function evaluate(FlowQuery $flowQuery, array $arguments)
 {
     $output = array();
     $outputNodePaths = array();
     foreach ($flowQuery->getContext() as $contextNode) {
         $parentNode = $contextNode->getParent();
         if ($parentNode !== null && !isset($outputNodePaths[$parentNode->getPath()])) {
             $output[] = $parentNode;
             $outputNodePaths[$parentNode->getPath()] = true;
         }
     }
     $flowQuery->setContext($output);
     if (isset($arguments[0]) && !empty($arguments[0])) {
         $flowQuery->pushOperation('filter', $arguments);
     }
 }
 /**
  * {@inheritdoc}
  *
  * @param \TYPO3\Eel\FlowQuery\FlowQuery $flowQuery the FlowQuery object
  * @param array $arguments the elements to add (as array in index 0)
  * @return void
  */
 public function evaluate(\TYPO3\Eel\FlowQuery\FlowQuery $flowQuery, array $arguments)
 {
     $output = array();
     foreach ($flowQuery->getContext() as $element) {
         $output[] = $element;
     }
     if (isset($arguments[0])) {
         if (is_array($arguments[0]) || $arguments[0] instanceof \Traversable) {
             foreach ($arguments[0] as $element) {
                 $output[] = $element;
             }
         } else {
             $output[] = $arguments[0];
         }
     }
     $flowQuery->setContext($output);
 }
 /**
  * {@inheritdoc}
  *
  * @param \TYPO3\Eel\FlowQuery\FlowQuery $flowQuery the FlowQuery object
  * @param array $arguments the arguments for this operation
  * @return mixed|null if the operation is final, the return value
  */
 public function evaluate(\TYPO3\Eel\FlowQuery\FlowQuery $flowQuery, array $arguments)
 {
     $output = array();
     $outputNodePaths = array();
     foreach ($flowQuery->getContext() as $contextNode) {
         foreach ($contextNode->getChildNodes() as $childNode) {
             if (!isset($outputNodePaths[$childNode->getPath()])) {
                 $output[] = $childNode;
                 $outputNodePaths[$childNode->getPath()] = TRUE;
             }
         }
     }
     $flowQuery->setContext($output);
     if (isset($arguments[0]) && !empty($arguments[0])) {
         $flowQuery->pushOperation('filter', $arguments);
     }
 }
Beispiel #30
0
 /**
  * @param FlowQuery $flowQuery the FlowQuery object
  * @param array $arguments the arguments for this operation
  * @return void
  */
 public function evaluate(FlowQuery $flowQuery, array $arguments)
 {
     $user = false;
     if (count($arguments) > 0 && is_string($arguments[0])) {
         $user = $this->apiConnector->fetchUser($arguments[0]);
     }
     if ($user) {
         $groups = $this->apiConnector->fetchGroups();
         $user['memberships'] = array_filter($groups, function ($group) use($user) {
             return in_array($user['name'], $group['members']) && isset($group['neos_group_type']) && !empty($group['neos_group_type']);
         });
         $user['additionalProperties'] = array_filter($user, function ($key) {
             return strpos($key, 'neos_') === 0;
         }, ARRAY_FILTER_USE_KEY);
     }
     $flowQuery->setContext($user);
 }