Skip to content

Commit 53b8731

Browse files
exaby73transistive
authored andcommitted
refactor: Bring back EventHandler and fix CS
1 parent 385614f commit 53b8731

File tree

5 files changed

+101
-3
lines changed

5 files changed

+101
-3
lines changed

config/services.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use Laudis\Neo4j\Contracts\TransactionInterface;
99
use Neo4j\Neo4jBundle\ClientFactory;
1010
use Neo4j\Neo4jBundle\EventHandler;
11-
use Neo4j\Neo4jBundle\EventListener\Neo4jProfileListener;
1211
use Neo4j\Neo4jBundle\SymfonyClient;
1312
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
1413

src/DependencyInjection/Neo4jExtension.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
namespace Neo4j\Neo4jBundle\DependencyInjection;
66

7-
use Neo4j\Neo4jBundle\Collector\Neo4jDataCollector;
8-
use Neo4j\Neo4jBundle\EventListener\Neo4jProfileListener;
97
use Psr\Http\Client\ClientInterface;
108
use Psr\Http\Message\RequestFactoryInterface;
119
use Psr\Http\Message\StreamFactoryInterface;

src/Event/FailureEvent.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Neo4j\Neo4jBundle\Event;
6+
7+
use Laudis\Neo4j\Databags\Statement;
8+
use Laudis\Neo4j\Exception\Neo4jException;
9+
use Symfony\Contracts\EventDispatcher\Event;
10+
11+
class FailureEvent extends Event
12+
{
13+
public const EVENT_ID = 'neo4j.on_failure';
14+
15+
protected bool $shouldThrowException = true;
16+
17+
public function __construct(private ?string $alias, private Statement $statement, private Neo4jException $exception)
18+
{
19+
}
20+
21+
public function getException(): Neo4jException
22+
{
23+
return $this->exception;
24+
}
25+
26+
public function disableException(): void
27+
{
28+
$this->shouldThrowException = false;
29+
}
30+
31+
public function shouldThrowException(): bool
32+
{
33+
return $this->shouldThrowException;
34+
}
35+
36+
public function getAlias(): ?string
37+
{
38+
return $this->alias;
39+
}
40+
41+
public function getStatement(): Statement
42+
{
43+
return $this->statement;
44+
}
45+
}

src/Event/PostRunEvent.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Neo4j\Neo4jBundle\Event;
6+
7+
use Laudis\Neo4j\Databags\ResultSummary;
8+
use Symfony\Contracts\EventDispatcher\Event;
9+
10+
class PostRunEvent extends Event
11+
{
12+
public const EVENT_ID = 'neo4j.post_run';
13+
14+
public function __construct(
15+
private ?string $alias,
16+
private ResultSummary $result
17+
) {
18+
}
19+
20+
public function getResult(): ResultSummary
21+
{
22+
return $this->result;
23+
}
24+
25+
public function getAlias(): ?string
26+
{
27+
return $this->alias;
28+
}
29+
}

src/Event/PreRunEvent.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Neo4j\Neo4jBundle\Event;
6+
7+
use Laudis\Neo4j\Databags\Statement;
8+
use Symfony\Contracts\EventDispatcher\Event;
9+
10+
class PreRunEvent extends Event
11+
{
12+
public const EVENT_ID = 'neo4j.pre_run';
13+
14+
public function __construct(private ?string $alias, private Statement $statement)
15+
{
16+
}
17+
18+
public function getStatement(): Statement
19+
{
20+
return $this->statement;
21+
}
22+
23+
public function getAlias(): ?string
24+
{
25+
return $this->alias;
26+
}
27+
}

0 commit comments

Comments
 (0)