|
3 | 3 | namespace Overblog\GraphQLBundle\Event; |
4 | 4 |
|
5 | 5 | use GraphQL\Error\Error; |
6 | | -use Symfony\Component\EventDispatcher\Event; |
| 6 | +use Symfony\Contracts\EventDispatcher\Event; |
7 | 7 |
|
8 | | -final class ErrorFormattingEvent extends Event |
9 | | -{ |
10 | | - /** @var Error */ |
11 | | - private $error; |
| 8 | +// TODO(mcg-web): remove hack after migrating Symfony >= 4.3 |
| 9 | +if (EventDispatcherVersionHelper::isForLegacy()) { |
| 10 | + final class ErrorFormattingEvent extends \Symfony\Component\EventDispatcher\Event |
| 11 | + { |
| 12 | + /** @var Error */ |
| 13 | + private $error; |
12 | 14 |
|
13 | | - /** @var \ArrayObject */ |
14 | | - private $formattedError; |
| 15 | + /** @var \ArrayObject */ |
| 16 | + private $formattedError; |
15 | 17 |
|
16 | | - public function __construct(Error $error, array $formattedError) |
17 | | - { |
18 | | - $this->error = $error; |
19 | | - $this->formattedError = new \ArrayObject($formattedError); |
20 | | - } |
| 18 | + public function __construct(Error $error, array $formattedError) |
| 19 | + { |
| 20 | + $this->error = $error; |
| 21 | + $this->formattedError = new \ArrayObject($formattedError); |
| 22 | + } |
21 | 23 |
|
22 | | - public function getError() |
23 | | - { |
24 | | - return $this->error; |
25 | | - } |
| 24 | + public function getError() |
| 25 | + { |
| 26 | + return $this->error; |
| 27 | + } |
26 | 28 |
|
27 | | - /** |
28 | | - * @return \ArrayObject |
29 | | - */ |
30 | | - public function getFormattedError() |
| 29 | + /** |
| 30 | + * @return \ArrayObject |
| 31 | + */ |
| 32 | + public function getFormattedError() |
| 33 | + { |
| 34 | + return $this->formattedError; |
| 35 | + } |
| 36 | + } |
| 37 | +} else { |
| 38 | + final class ErrorFormattingEvent extends Event |
31 | 39 | { |
32 | | - return $this->formattedError; |
| 40 | + /** @var Error */ |
| 41 | + private $error; |
| 42 | + |
| 43 | + /** @var \ArrayObject */ |
| 44 | + private $formattedError; |
| 45 | + |
| 46 | + public function __construct(Error $error, array $formattedError) |
| 47 | + { |
| 48 | + $this->error = $error; |
| 49 | + $this->formattedError = new \ArrayObject($formattedError); |
| 50 | + } |
| 51 | + |
| 52 | + public function getError() |
| 53 | + { |
| 54 | + return $this->error; |
| 55 | + } |
| 56 | + |
| 57 | + /** |
| 58 | + * @return \ArrayObject |
| 59 | + */ |
| 60 | + public function getFormattedError() |
| 61 | + { |
| 62 | + return $this->formattedError; |
| 63 | + } |
33 | 64 | } |
34 | 65 | } |
0 commit comments