-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #67 from Codeception/8.0-symfony5
Symfony5: DispatcherWrapper hides dispatch differences
- Loading branch information
Showing
3 changed files
with
41 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace Codeception\PHPUnit; | ||
|
||
use Symfony\Component\EventDispatcher\Event; | ||
use Symfony\Component\EventDispatcher\EventDispatcher; | ||
|
||
trait DispatcherWrapper | ||
{ | ||
/** | ||
* Compatibility wrapper for dispatcher change between Symfony 4 and 5 | ||
* @param EventDispatcher $dispatcher | ||
* @param string $eventType | ||
* @param Event $eventObject | ||
*/ | ||
protected function dispatch(EventDispatcher $dispatcher, $eventType, Event $eventObject) | ||
{ | ||
if (class_exists('Symfony\Contracts\EventDispatcher\Event')) { | ||
//Symfony 5 | ||
$dispatcher->dispatch($eventObject, $eventType); | ||
} else { | ||
//Symfony 2,3 or 4 | ||
$dispatcher->dispatch($eventType, $eventObject); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters