00001 <?php
00002
00003
00004
00005
00006
00007
00008 class ControllerDefaultClassInstantiater implements IClassInstantiater {
00009 public function get_all() {
00010 $ret = array();
00011 $dirs = Load::get_base_directories();
00012 foreach($dirs as $dir) {
00013 $ret = array_merge($ret, $this->instantiate_direcory($dir));
00014 }
00015 return $ret;
00016 }
00017
00018 protected function instantiate_direcory($directory) {
00019 $ret = array();
00020 foreach (gyro_glob($directory . 'controller/*.controller.php') as $inc) {
00021 include_once($inc);
00022
00023
00024
00025 $controllername = basename($inc, '.php');
00026 $controllername = strtr($controllername, '.-_', ' ');
00027 $controllername = ucwords($controllername);
00028 $controllername = str_replace(' ', '', $controllername);
00029 if (class_exists($controllername)) {
00030 $ret[] = new $controllername;
00031 }
00032 else {
00033 throw new Exception(tr('Controller %c not found', 'core', array('%c' => $controllername)));
00034 }
00035 }
00036 return $ret;
00037 }
00038 }