Exemplo n.º 1
0
Arquivo: App.php Projeto: a3gz/chubby
 /**
  * @inheritdoc
  */
 public function run($appNamespace = self::ROOT_NAMESPACE)
 {
     //
     // Each application must exist inside its own namespace. Chubby uses that namespace to search for modules.
     $this->appNamespace = $appNamespace;
     //
     // Slim can be initiated in one of two ways:
     // 1. Without a container. Slim will create the default container.
     // 2. Receiving a container in the constructor. We can pass Slim some settings and services
     //      by passing a pre-created container. We do this here via a configuration file.
     $container = $this->getContainerConfig();
     $this->slim = new \Slim\App($container);
     $container = $this->slim->getContainer();
     //
     $this->modules = \Chubby\PackageLoader::loadModules($container);
     if (!is_array($this->modules) || !count($this->modules)) {
         throw new \Exception("Chubby Framework requires at least one module.");
     }
     //
     // Initialize the modules following the order given by each module's priority.
     foreach ($this->modules as $priority => $modules) {
         foreach ($modules as $module) {
             $module['object']->setApp($this);
             $module['object']->init();
         }
     }
     //
     $this->slim->run();
     return $this;
 }