Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/EventRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ public function getAllActiveEvents(): array
*/
public function getEventClassName(string $event)
{
// if the event is already a class name, use it
if (class_exists($event)) {
return $event;
}

if (isset(self::$eventsMap[$event])) {
return self::$eventsMap[$event];
}
Expand Down
9 changes: 9 additions & 0 deletions tests/EventRegistryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Symfony\Bundle\MakerBundle\EventRegistry;
use Symfony\Component\Console\Event\ConsoleCommandEvent;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpKernel\Event\ControllerEvent;
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
use Symfony\Component\HttpKernel\KernelEvents;

Expand Down Expand Up @@ -84,6 +85,14 @@ public function testGetNewEventClassNameFromStandardList()
$registry = new EventRegistry($dispatcher);
$this->assertSame(ExceptionEvent::class, $registry->getEventClassName(KernelEvents::EXCEPTION));
}

public function testGetEventClassNameGivenEventAsClass()
{
$dispatcher = $this->createMock(EventDispatcherInterface::class);

$registry = new EventRegistry($dispatcher);
$this->assertSame(ControllerEvent::class, $registry->getEventClassName(ControllerEvent::class));
}
}

class DummyEvent
Expand Down