Example #1
0
File: App.php Project: NePTeR/sonic
 /**
  * pushes over the first domino
  *
  * @param string $mode
  * @param bool $load used for unit tests to prevent fatal errors
  * @return void
  */
 public function start($mode = self::WEB, $load = true)
 {
     if ($this->_delegate) {
         $this->_delegate->appStartedLoading($mode);
     }
     $this->addSetting(self::MODE, $mode);
     // this could use App::includeFile() but it is faster to duplicate
     // that logic here
     if ($load) {
         include 'Sonic/Exception.php';
         $this->_included['Sonic/Exception.php'] = true;
         include 'Sonic/Request.php';
         $this->_included['Sonic/Request.php'] = true;
         include 'Sonic/Router.php';
         $this->_included['Sonic/Router.php'] = true;
         include 'Sonic/Controller.php';
         $this->_included['Sonic/Controller.php'] = true;
         include 'Sonic/View.php';
         $this->_included['Sonic/View.php'] = true;
         include 'Sonic/Layout.php';
         $this->_included['Sonic/Layout.php'] = true;
     }
     if ($this->getSetting(self::AUTOLOAD)) {
         $this->autoload();
     }
     if ($this->_delegate) {
         $this->_delegate->appFinishedLoading();
     }
     // if we are calling this app from command line then all we want to do
     // is load the core application files
     if ($mode != self::WEB) {
         return;
     }
     if ($this->getSetting(self::TURBO) && $this->_robotnikWins()) {
         $this->addSetting(self::TURBO, false);
     }
     // try to get the controller and action
     // if an exception is thrown that means the page requested does not exist
     $controller = $this->getRequest()->getControllerName();
     $action = $this->getRequest()->getAction();
     if ($this->_delegate) {
         $this->_delegate->appStartedRunning();
     }
     $this->runController($controller, $action);
     if ($this->_delegate) {
         $this->_delegate->appFinishedRunning();
     }
 }