Skip to content

Commit 0060d3b

Browse files
author
Jeremiah VALERIE
committed
Fix Event deprecations messages
1 parent 888f0c5 commit 0060d3b

File tree

7 files changed

+380
-166
lines changed

7 files changed

+380
-166
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
- php: 7.3
4848
env: SYMFONY_VERSION=4.2.*
4949
- php: 7.3
50-
env: SYMFONY_VERSION=4.3.*
50+
env: SYMFONY_VERSION=4.3.* SYMFONY_DEPRECATIONS_HELPER=max[total]=0
5151
- php: nightly
5252
env: COMPOSER_UPDATE_FLAGS=--ignore-platform-reqs
5353

src/Event/ErrorFormattingEvent.php

Lines changed: 52 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,63 @@
33
namespace Overblog\GraphQLBundle\Event;
44

55
use GraphQL\Error\Error;
6-
use Symfony\Component\EventDispatcher\Event;
6+
use Symfony\Contracts\EventDispatcher\Event;
77

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;
1214

13-
/** @var \ArrayObject */
14-
private $formattedError;
15+
/** @var \ArrayObject */
16+
private $formattedError;
1517

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+
}
2123

22-
public function getError()
23-
{
24-
return $this->error;
25-
}
24+
public function getError()
25+
{
26+
return $this->error;
27+
}
2628

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
3139
{
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+
}
3364
}
3465
}

src/Event/EventDispatcherVersionHelper.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
/**
99
* @internal
10+
* TODO(mcg-web): delete hack after migrating Symfony >= 4.3
1011
*/
1112
final class EventDispatcherVersionHelper
1213
{

0 commit comments

Comments
 (0)