/** * @param StackInterface $stack * * @return ResultCollection|null * * @throws Neo4jException */ public function runStack(StackInterface $stack) { $pipeline = $this->pipeline(null, null, $stack->getTag(), $stack->getConnectionAlias()); foreach ($stack->statements() as $statement) { $pipeline->push($statement->text(), $statement->parameters(), $statement->getTag()); } $this->eventDispatcher->dispatch(Neo4jClientEvents::NEO4J_PRE_RUN, new PreRunEvent($stack->statements())); try { $results = $pipeline->run(); $this->eventDispatcher->dispatch(Neo4jClientEvents::NEO4J_POST_RUN, new PostRunEvent($results)); } catch (Neo4jException $e) { $event = new FailureEvent($e); $this->eventDispatcher->dispatch(Neo4jClientEvents::NEO4J_ON_FAILURE, $event); if ($event->shouldThrowException()) { throw $e; } return; } return $results; }