public function evaluate(FlowQuery $flowQuery, array $arguments)
{
if (!isset($arguments[0]) || empty($arguments[0])) {
return;
}
if ($arguments[0] instanceof NodeInterface) {
$filteredContext = array();
$context = $flowQuery->getContext();
foreach ($context as $element) {
if ($element === $arguments[0]) {
$filteredContext[] = $element;
break;
}
}
$flowQuery->setContext($filteredContext);
} else {
parent::evaluate($flowQuery, $arguments);
}
}
/** * @test */ public function filterWithNodeInstanceIsSupported() { $node1 = $this->createMock(NodeInterface::class); $node2 = $this->createMock(NodeInterface::class); $context = array($node1, $node2); $q = new FlowQuery($context); $operation = new FilterOperation(); $operation->evaluate($q, array($node2)); $this->assertEquals(array($node2), $q->getContext()); }