/** * Init the module requested */ private static function initModule() { if (!self::$module) { self::$module = factory::getModule(self::$uriInfo['module'], array(), self::$scaffold, self::$cfg->allowScaffold); if (self::$module instanceof module_scaffold_controller && !self::$cfg->allowScaffold) { // Need to test if the action was expressly defined $ref = new nReflection(); $className = 'module_'.self::$uriInfo['module'].'_controller'; $prefix = null; $action = self::$uriInfo['action']; if (array_key_exists(NYROENV, self::$module->getCfg()->basicPrefixExec) && in_array($action, self::$module->getCfg()->getInArray('basicPrefixExec', NYROENV))) $prefix = ucfirst(NYROENV); else if (self::$module->getCfg()->prefixExec && !in_array($action, self::$module->getCfg()->noPrefixExec)) $prefix = self::$module->getCfg()->prefixExec; $exec = 'exec'.$prefix.ucFirst($action); if ($ref->rebuild($className)) { if ($ref->getMethod($exec)->getDeclaringClass()->name != $className) throw new module_exception('Request - initModule: '.self::$uriInfo['module'].'.'.$exec.' not found.'); } } if (self::$scaffold) { self::$uriInfo['moduleScaffold'] = self::$uriInfo['module']; self::$uriInfo['module'] = 'scaffold'; } } }
/** * Get a new object, with loading its definition and configuration * * @param string $className The classname to create * @param array $cfg The config * @return object The new object */ public static function get($className, array $cfg = array()) { if (self::$cfg && ($tmp = self::$cfg->getInArray('classAlias', $className))) { $className = $tmp; } self::load($className); $ref = new nReflection(); if ($ref->rebuild($className)) { $prm = self::loadCfg($className); self::mergeCfg($prm, $cfg); $inst = $ref->newInstanceCfg(new config($prm)); return $inst; } else { throw new nException('Factory - load: Unable to bluid ' . $className . '.'); } }