private static function runBootstrap($bootstrap) { self::$bootstrap = new $bootstrap(); $classname = 'Core_Config_IApplication'; if (!self::$bootstrap instanceof $classname) { throw new Core_Exceptions("Bootstrap is not implementing Core_Config_IApplication interface"); } self::setSessionHandler(self::$bootstrap->getSessionTypeFile()); self::$bootstrap->run(); self::$acl = self::$bootstrap->getAcl(); self::$acl->validate(); self::$templates = self::$bootstrap->getTemplates(); self::setActiveTemplate(self::$bootstrap->getActiveTemplate()); self::$router = self::$bootstrap->getRouter(); }
public function dispatch($method, $arguments) { $callMethod = $method . '_'; $defaultMethod = 'index'; switch ($this->method) { case 'GET': $defaultMethod = 'index'; break; case 'POST': $defaultMethod = 'create'; break; case 'PUT': $defaultMethod = 'update'; break; case 'DELETE': $defaultMethod = 'destroy'; break; default: break; } if ($method == 'new' || isset($arguments[0]) && $arguments[0] == 'new') { $defaultMethod = 'create'; } $callMethod = $callMethod . $defaultMethod; if (method_exists($this, $callMethod)) { call_user_func_array(array(Application::router()->getController(), $callMethod), $arguments); } else { if (method_exists($this, $defaultMethod)) { array_unshift($arguments, $method); call_user_func_array(array(Application::router()->getController(), $defaultMethod), $arguments); } else { array_unshift($arguments, $method); call_user_func_array(array(Application::router()->getController(), "default"), $arguments); } } }