public function __construct($moduleName, $directory, \Hatcher\Application $application)
 {
     $di = new DirectoryDi($directory . '/services', [$this]);
     $di->set('router', function (BaseModule $module) {
         $router = new Router();
         call_user_func(require $module->resolvePath('routes.php'), $router);
         return $router;
     });
     parent::__construct($moduleName, $directory, $application, $di);
 }
 private function dispatchAction(Route $route, ServerRequestInterface $request)
 {
     $data = $route->handler;
     if (null === $data) {
         $data = ['action' => $route->name];
     } elseif (is_string($data)) {
         $data = ['action' => $data];
     }
     if (!isset($data['action'])) {
         throw new Exception('No action found in the route ' . $route->name);
     }
     $actionFile = $this->module->resolvePath('actions/' . $data['action'] . '.php');
     if (!file_exists($actionFile)) {
         throw new Exception('Action file does not exist: ' . $actionFile);
     }
     $action = (require $actionFile);
     if (!$action instanceof Action) {
         throw new Exception('action ' . $data['name'] . ' is not an instance of Hatcher\\Action');
     }
     $action->init($request, $route, $this->module);
     return $action->execute();
 }
 public function __get($name)
 {
     return $this->module->getDI()->get($name);
 }