Пример #1
0
 /**
  * @param array $config
  * @return MvcDispatcher
  */
 public static function createMvcFrom(array $config) : MvcDispatcher
 {
     $dispatcher = new MvcDispatcher();
     $dispatcher->setEventsManager(new EventManager());
     $dispatcher->setControllerSuffix(null);
     $dispatcher->setDefaultNamespace($config['controllerDefaultNamespace']);
     $dispatcher->getEventsManager()->attach('dispatch:afterDispatchLoop', function (Event $event, MvcDispatcher $dispatcher) {
         if ($dispatcher->getReturnedValue() instanceof \Phalcon\Http\Response) {
             $dispatcher->getDI()->setShared('response', $dispatcher->getReturnedValue());
         }
     });
     return $dispatcher;
 }