Skip to content
This repository has been archived by the owner on Dec 1, 2021. It is now read-only.

Symphony EventDispatcher update to v5 #177

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"ext-mbstring": "*",
"graphaware/neo4j-common": "^3.4",
"graphaware/neo4j-bolt": "^1.5",
"symfony/event-dispatcher": "^2.7 || ^3.0 || ^4.0",
"symfony/event-dispatcher": "^2.7 || ^3.0 || ^4.0 || ^5.0",
"myclabs/php-enum": "^1.4",
"php-http/httplug": "^1.0",
"php-http/message-factory": "^1.0",
Expand Down
12 changes: 6 additions & 6 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ public function run($query, $parameters = null, $tag = null, $connectionAlias =
$connection = $this->connectionManager->getConnection($connectionAlias);
$params = null !== $parameters ? $parameters : [];
$statement = Statement::create($query, $params, $tag);
$this->eventDispatcher->dispatch(Neo4jClientEvents::NEO4J_PRE_RUN, new PreRunEvent([$statement]));
$this->eventDispatcher->dispatch(new PreRunEvent([$statement]), Neo4jClientEvents::NEO4J_PRE_RUN);

try {
$result = $connection->run($query, $parameters, $tag);
$this->eventDispatcher->dispatch(Neo4jClientEvents::NEO4J_POST_RUN, new PostRunEvent(ResultCollection::withResult($result)));
$this->eventDispatcher->dispatch(new PostRunEvent(ResultCollection::withResult($result)), Neo4jClientEvents::NEO4J_POST_RUN);
} catch (Neo4jException $e) {
$event = new FailureEvent($e);
$this->eventDispatcher->dispatch(Neo4jClientEvents::NEO4J_ON_FAILURE, $event);
$this->eventDispatcher->dispatch($event, Neo4jClientEvents::NEO4J_ON_FAILURE);

if ($event->shouldThrowException()) {
throw $e;
Expand Down Expand Up @@ -141,14 +141,14 @@ public function runStack(StackInterface $stack)
$pipeline->push($statement->text(), $statement->parameters(), $statement->getTag());
}

$this->eventDispatcher->dispatch(Neo4jClientEvents::NEO4J_PRE_RUN, new PreRunEvent($stack->statements()));
$this->eventDispatcher->dispatch(new PreRunEvent($stack->statements()), Neo4jClientEvents::NEO4J_PRE_RUN);

try {
$results = $pipeline->run();
$this->eventDispatcher->dispatch(Neo4jClientEvents::NEO4J_POST_RUN, new PostRunEvent($results));
$this->eventDispatcher->dispatch(new PostRunEvent($results), Neo4jClientEvents::NEO4J_POST_RUN);
} catch (Neo4jException $e) {
$event = new FailureEvent($e);
$this->eventDispatcher->dispatch(Neo4jClientEvents::NEO4J_ON_FAILURE, $event);
$this->eventDispatcher->dispatch($event, Neo4jClientEvents::NEO4J_ON_FAILURE);

if ($event->shouldThrowException()) {
throw $e;
Expand Down
2 changes: 1 addition & 1 deletion src/Event/FailureEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace GraphAware\Neo4j\Client\Event;

use GraphAware\Neo4j\Client\Exception\Neo4jExceptionInterface;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Contracts\EventDispatcher\Event;

class FailureEvent extends Event
{
Expand Down
2 changes: 1 addition & 1 deletion src/Event/PostRunEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace GraphAware\Neo4j\Client\Event;

use GraphAware\Common\Result\ResultCollection;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Contracts\EventDispatcher\Event;

class PostRunEvent extends Event
{
Expand Down
2 changes: 1 addition & 1 deletion src/Event/PreRunEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace GraphAware\Neo4j\Client\Event;

use GraphAware\Common\Cypher\StatementInterface;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Contracts\EventDispatcher\Event;

class PreRunEvent extends Event
{
Expand Down
12 changes: 6 additions & 6 deletions src/Transaction/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,16 @@ public function run($statement, array $parameters = [], $tag = null)
$this->driverTransaction->begin();
}
$stmt = Statement::create($statement, $parameters, $tag);
$this->eventDispatcher->dispatch(Neo4jClientEvents::NEO4J_PRE_RUN, new PreRunEvent([$stmt]));
$this->eventDispatcher->dispatch(new PreRunEvent([$stmt]), Neo4jClientEvents::NEO4J_PRE_RUN);
try {
$result = $this->driverTransaction->run(Statement::create($statement, $parameters, $tag));
$this->eventDispatcher->dispatch(Neo4jClientEvents::NEO4J_POST_RUN, new PostRunEvent(ResultCollection::withResult($result)));
$this->eventDispatcher->dispatch(new PostRunEvent(ResultCollection::withResult($result)), Neo4jClientEvents::NEO4J_POST_RUN);
} catch (MessageFailureException $e) {
$exception = new Neo4jException($e->getMessage());
$exception->setNeo4jStatusCode($e->getStatusCode());

$event = new FailureEvent($exception);
$this->eventDispatcher->dispatch(Neo4jClientEvents::NEO4J_ON_FAILURE, $event);
$this->eventDispatcher->dispatch($event, Neo4jClientEvents::NEO4J_ON_FAILURE);
if ($event->shouldThrowException()) {
throw $exception;
}
Expand Down Expand Up @@ -126,16 +126,16 @@ public function runStack(StackInterface $stack)
$sts[] = $statement;
}

$this->eventDispatcher->dispatch(Neo4jClientEvents::NEO4J_PRE_RUN, new PreRunEvent($stack->statements()));
$this->eventDispatcher->dispatch(new PreRunEvent($stack->statements()), Neo4jClientEvents::NEO4J_PRE_RUN);
try {
$results = $this->driverTransaction->runMultiple($sts);
$this->eventDispatcher->dispatch(Neo4jClientEvents::NEO4J_POST_RUN, new PostRunEvent($results));
$this->eventDispatcher->dispatch(new PostRunEvent($results), Neo4jClientEvents::NEO4J_POST_RUN);
} catch (MessageFailureException $e) {
$exception = new Neo4jException($e->getMessage());
$exception->setNeo4jStatusCode($e->getStatusCode());

$event = new FailureEvent($exception);
$this->eventDispatcher->dispatch(Neo4jClientEvents::NEO4J_ON_FAILURE, $event);
$this->eventDispatcher->dispatch($event, Neo4jClientEvents::NEO4J_ON_FAILURE);
if ($event->shouldThrowException()) {
throw $exception;
}
Expand Down