コード例 #1
0
ファイル: preDispatcher.php プロジェクト: dariushha/zinux
 /**
  * Runs every function in {MODULE}\BootStrap.php function which end with 'Init' or starts with 'pre_' in function's name
  * @param Request $request 
  */
 protected function RunBootstarp(request &$request)
 {
     # both possible naming for bootstrap
     $bsfiles_path = array();
     # we really don't want to confuse our selves
     # $bsfiles_path[] = array($request->module->full_name, $request->module->GetPath()."/{$request->module->full_name}Bootstrap.php");
     $bsfiles_path[] = array($request->module->name, $request->module->GetPath() . "/{$request->module->name}Bootstrap.php");
     foreach ($bsfiles_path as $bs) {
         $bs[1] = \zinux\kernel\utilities\fileSystem::resolve_path($bs[1]);
         if (file_exists($bs[1])) {
             require_once $bs[1];
             $cname = "{$request->module->GetNameSpace()}\\{$bs[0]}Bootstrap";
             if (class_exists($cname)) {
                 $c = new $cname();
                 $m = get_class_methods($c);
                 foreach ($m as $method) {
                     if (\zinux\kernel\utilities\string::endsWith(strtoupper($method), "INIT") || \zinux\kernel\utilities\string::startsWith(strtoupper($method), "PRE_")) {
                         if (!is_callable(array($c, $method))) {
                             trigger_error("The method {$method} found in bootstrap file `{$bs[1]}` but is not callable");
                         } else {
                             $c->{$method}($request);
                         }
                     }
                 }
             }
         }
     }
 }
コード例 #2
0
ファイル: mvc.php プロジェクト: dariushha/zinux
 public function SetPath($path, $throw_exception_if_not_exists = 1)
 {
     $this->path = \zinux\kernel\utilities\fileSystem::resolve_path($path, 1);
     if ($throw_exception_if_not_exists && !$this->path) {
         throw new \zinux\kernel\exceptions\notFoundException("`{$path}` does not exists ...");
     }
 }
コード例 #3
0
ファイル: plugin.php プロジェクト: dariushha/zinux
 /**
  * check if a plug in with a name registered?
  * @param string $name plugin's name
  * @return boolean
  */
 public function isPluginRegistered($name_or_path)
 {
     if (isset(self::$plug_lists[$name_or_path])) {
         return self::$plug_lists[$name_or_path];
     }
     $name_or_path = \zinux\kernel\utilities\fileSystem::resolve_path($name_or_path);
     if (isset(self::$raw_list[$name_or_path])) {
         return $name_or_path;
     }
     return FALSE;
 }
コード例 #4
0
ファイル: request.php プロジェクト: dariushha/zinux
 /**
  * Fetch controller name according to URI
  */
 protected function FetchControllerName()
 {
     # default controller
     $this->controller = new \zinux\kernel\mvc\controller("index", $this->module);
     # head for locating controller
     if (isset($this->_parts[0]) && ($file = \zinux\kernel\utilities\fileSystem::resolve_path($this->controller->GetRootDirectory() . $this->_parts[0] . "Controller.php"))) {
         # updating target controller's info
         $this->controller = new \zinux\kernel\mvc\controller($this->_parts[0], $this->module);
         array_shift($this->_parts);
     } elseif ($file = \zinux\kernel\utilities\fileSystem::resolve_path($this->controller->GetRootDirectory() . "indexController.php")) {
         $this->controller = new \zinux\kernel\mvc\controller("index", $this->module);
     }
     # we found target file
     # validating controller
     if (!$this->controller->Load() || !$this->controller->CheckControllerExists()) {
         # we don't have our class
         throw new \zinux\kernel\exceptions\notFoundException("The controller `{$this->controller->GetClassFullName()}` does not exists at `{$this->controller->GetPath()}`!");
     }
     if (!$this->controller->IsValid()) {
         throw new \ReflectionException("The controller `{$this->controller->full_name}` is not instanceof `\\zinux\\kernel\\controller\\baseController`");
     }
 }
コード例 #5
0
ファイル: iniParser.php プロジェクト: dariushha/zinux
 /**
  * @param string $config_file_address config file address
  * @param string $section_name section_name in ini file
  * @throws \zinux\kernel\exceptions\invalidArgumentException
  */
 public function __construct($config_file_address, $section_name = NULL)
 {
     $this->file_address = \zinux\kernel\utilities\fileSystem::resolve_path($config_file_address);
     if (!$this->file_address) {
         throw new \zinux\kernel\exceptions\invalidArgumentException("config file not found at '{$config_file_address}'");
     }
     $this->process_sections = isset($section_name);
     $this->section_name = $section_name;
 }
コード例 #6
0
ファイル: application.php プロジェクト: dariushha/zinux
 /**
  * Startup and making application's ready with passed configuration file [ Loads configurations and db ]
  * 
  * @param config_file_address
  */
 public function Startup()
 {
     # no initializer return
     if (!$this->config_initializer) {
         goto __INITIALIZERS;
     }
     # create config instance
     $config = new config($this->config_initializer);
     # load configs
     $config->Load();
     __INITIALIZERS:
     if ($this->initializers) {
         foreach ($this->initializers as $initializer) {
             $initializer->Initiate();
             $initializer->Execute($this->request);
         }
     }
     # set default module root
     defined('MODULE_ROOT') || define('MODULE_ROOT', \zinux\kernel\utilities\fileSystem::resolve_path(ZINUX_ROOT . '/../modules/') . "/");
     # check startup invoked
     $this->_startup_invoked = true;
     # return this instance
     return $this;
 }