public function initialize() { $app = $this->app; if ($app['setup']) { $this->addView('setup', new Setup($app)); } else { $cacheName = sha1(__CLASS__ . '_backendClasses'); $backendClasses = $app->cache->load($cacheName); if ($backendClasses === false) { $backendClasses = array(); $classes = ClassEnumerator::findClasses(__DIR__ . '/../Backend'); foreach ($classes as $className) { if (class_exists($className) && $className !== __CLASS__ && $className !== 'Curry\\Backend\\Setup') { $r = new \ReflectionClass($className); if ($r->isSubclassOf('Curry\\Backend\\AbstractBackend') && !$r->isAbstract()) { $backendClasses[strtolower($r->getShortName())] = $className; } } } $app->cache->save($backendClasses, $cacheName); } foreach ($backendClasses as $viewName => $className) { $this->addView($viewName, new $className($this->app)); } } }
/** * Get a list of all available modules. * * @return array */ public static function getModuleList() { if (self::$modules) { return self::$modules; } // find all backend directories $dirs = glob(PathHelper::path(App::getInstance()['projectPath'], 'include', '*', 'Module'), GLOB_ONLYDIR); if (!$dirs) { $dirs = array(); } $dirs[] = __DIR__; // find all php files in the directories $modules = array(); foreach ($dirs as $dir) { $classes = ClassEnumerator::findClasses($dir); foreach ($classes as $className) { if (class_exists($className)) { $r = new \ReflectionClass($className); if ($r->isSubclassOf(__CLASS__) && !$r->isAbstract()) { $modules[$className] = $className; } } } } ksort($modules); self::$modules = $modules; return self::$modules; }