public function initDispatcher()
    {
        $this->di->set('dispatcher', function() {
            $dispatcher = new Dispatcher();

            /**
             * @var \Phalcon\Events\Manager $eventsManager
             */
            $eventsManager = $this->di->getShared('eventsManager');
            $eventsManager->attach(
                'dispatch:beforeException',
                (new ExceptionListener())->beforeException()
            );

            $dispatcher->setEventsManager($eventsManager);

            return $dispatcher;
        });
    }