Skip to content

Commit

Permalink
refactor: Bring back EventHandler and fix CS
Browse files Browse the repository at this point in the history
  • Loading branch information
exaby73 committed Aug 28, 2024
1 parent 4c1a518 commit 5e6fdc5
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 3 deletions.
1 change: 0 additions & 1 deletion config/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Laudis\Neo4j\Contracts\TransactionInterface;
use Neo4j\Neo4jBundle\ClientFactory;
use Neo4j\Neo4jBundle\EventHandler;
use Neo4j\Neo4jBundle\EventListener\Neo4jProfileListener;
use Neo4j\Neo4jBundle\SymfonyClient;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

Expand Down
2 changes: 0 additions & 2 deletions src/DependencyInjection/Neo4jExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

namespace Neo4j\Neo4jBundle\DependencyInjection;

use Neo4j\Neo4jBundle\Collector\Neo4jDataCollector;
use Neo4j\Neo4jBundle\EventListener\Neo4jProfileListener;
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\RequestFactoryInterface;
use Psr\Http\Message\StreamFactoryInterface;
Expand Down
45 changes: 45 additions & 0 deletions src/Event/FailureEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

declare(strict_types=1);

namespace Neo4j\Neo4jBundle\Event;

use Laudis\Neo4j\Databags\Statement;
use Laudis\Neo4j\Exception\Neo4jException;
use Symfony\Contracts\EventDispatcher\Event;

class FailureEvent extends Event
{
public const EVENT_ID = 'neo4j.on_failure';

protected bool $shouldThrowException = true;

public function __construct(private ?string $alias, private Statement $statement, private Neo4jException $exception)
{
}

public function getException(): Neo4jException
{
return $this->exception;
}

public function disableException(): void
{
$this->shouldThrowException = false;
}

public function shouldThrowException(): bool
{
return $this->shouldThrowException;
}

public function getAlias(): ?string
{
return $this->alias;
}

public function getStatement(): Statement
{
return $this->statement;
}
}
29 changes: 29 additions & 0 deletions src/Event/PostRunEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

declare(strict_types=1);

namespace Neo4j\Neo4jBundle\Event;

use Laudis\Neo4j\Databags\ResultSummary;
use Symfony\Contracts\EventDispatcher\Event;

class PostRunEvent extends Event
{
public const EVENT_ID = 'neo4j.post_run';

public function __construct(
private ?string $alias,
private ResultSummary $result
) {
}

public function getResult(): ResultSummary
{
return $this->result;
}

public function getAlias(): ?string
{
return $this->alias;
}
}
27 changes: 27 additions & 0 deletions src/Event/PreRunEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

declare(strict_types=1);

namespace Neo4j\Neo4jBundle\Event;

use Laudis\Neo4j\Databags\Statement;
use Symfony\Contracts\EventDispatcher\Event;

class PreRunEvent extends Event
{
public const EVENT_ID = 'neo4j.pre_run';

public function __construct(private ?string $alias, private Statement $statement)
{
}

public function getStatement(): Statement
{
return $this->statement;
}

public function getAlias(): ?string
{
return $this->alias;
}
}

0 comments on commit 5e6fdc5

Please sign in to comment.