public function add_module($module) { if ($module instanceof \Module) { $GLOBALS['modules'][$module->name()] = $module; } else { $mod = \Launcher::boot($module); if ($mod instanceof \Module) { $GLOBALS['modules'][$mod->name()] = $mod; } } }
public function exec() { if ($this->get_option('bootable')) { $this->object = \Launcher::boot($this->object); } foreach ($this->get_option('methods') as $key => $value) { if (is_int($key)) { if (is_string($value)) { $this->set_result($value, call_user_func(array($this->object, $value))); } } elseif (is_string($key)) { $this->set_result($key, call_user_func_array(array($this->object, $key), $value)); } } return array($this->name() => $this->get_results()); }
protected function launch($element, $argument, $memoized) { if (is_array($element)) { $mem = array(); // Memoization foreach ($element as $sub) { $temp = $this->launch($sub, $argument, false); if (!is_null($temp)) { $mem[] = $temp; } } return $mem; } elseif ($element instanceof \collections\ILaunched) { $element->init($argument, $memoized); return $element->launch(NULL); } elseif ($element instanceof \Closure || is_callable($element)) { return $memoized ? call_user_func_array($element, $argument) : $element($argument); } elseif (\Launcher::can_boot($element)) { return \Launcher::boot($element); } return $element; // Default }
protected function exec_bootable($boot, $return) { if ($return) { return \Launcher::boot($boot); } else { \Launcher::boot($boot); } }
echo 'Hi !'; } elseif ($event == 'bye') { echo 'Bye !'; } else { echo 'Oh no ! ' . $event . ' isn\'t a proper event'; } } public function error($status) { echo 'Oh no ! Module error ' . $status; } } $Action = new Executors\Object('A', array('sayHi')); $Event = new Executors\Object('Event_A', array('valid')); $loader = new Loaders\Controller(); $loader->add_event($Event, $Action); $controller = $loader->load(); Launcher::boot($controller); // @TODO - Better support of functions/files to includes/bootables as actions in helpers // @TODO - change file names to ALL lowercases, easier to maintain (then change Get and Post class names to GET and POST, easier to read) // @TODO - Rewrites controllers and modules, and the way the latter handle model and view // @TODO - Rewrites router system, making it easier to use and more flexible // @TODO - Support [permmissions, errors, queries, form] IN controllers and separate (as other objects) in modules and controllers // @TODO - handles normal php options : ?id=1&page=3 etc... in router // @TODO - Error handling // @TODO - Find a way to implement libraries /* @TODO - In core : - Template -- Parsers : html, file inclusions etc... - Databases (ORM) */