Skip to content

ogizanagi/ogizanagi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 

Repository files navigation

class Kernel extends SymfonyKernel implements EventSubscriberInterface
{
    use MicroKernelTrait;

    public function bowtiesAction(): Response
    {
        return new RedirectResponse('I wear a fez now. Fezzes are cool!');
    }

    public function dangerousAction(): Response
    {
        throw new Danger('πŸ”₯πŸ”₯ 😈🐷 πŸ”±πŸ”Ί πŸ”₯πŸ”₯');
    }

    public function onKernelException(ExceptionEvent $event): void
    {
        if ($event->getThrowable() instanceof Danger) {
            $event->setResponse(new Response("πŸ‘΄πŸ»: It's dangerous to go alone. Take this: πŸ—‘οΈ"));
        }
    }

    protected function configureRoutes(RoutingConfigurator $routes): void
    {
        $routes->add('bowties', '/bowties')->controller('kernel::bowtiesAction');
        $routes->add('danger', '/danger')->controller('kernel::dangerousAction');
    }

    public static function getSubscribedEvents(): array
    {
        return [KernelEvents::EXCEPTION => 'onKernelException'];
    }
}