public static function init() { self::$_instance = \Zend_Controller_Front::getInstance(); foreach (Config::getPaths(Config::REALM_CONTROLLERS) as $controller) { list($path, $prefix) = explode(Config::PREFIX_SEPARATOR, $controller); self::$_routes[$prefix] = $path; } self::$_instance->setControllerDirectory(self::$_routes); }
public function loadTemplate($tpl, $module = null) { $paths = Config::getPaths(Config::REALM_TEMPLATES); if ($module) { $path = Core::$basePath . 'application/modules/' . $module . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR; if (is_dir($path)) { array_unshift($paths, $path); } } if (Core\Layout::$module) { $path = Core::$basePath . 'application/modules/' . Core\Layout::$vendor . DIRECTORY_SEPARATOR . Core\Layout::$moduleKey . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR; if (is_dir($path)) { array_unshift($paths, $path); } } $files = Config\Loader::findFile($tpl, $paths); foreach ($files[Config::DEFAULT_PREFIX] as $file) { if (file_exists($file)) { return $file; } } return false; }
/** * Looks for the given file name in all declared paths in ordered list for the given realm * Returns the full path of the matching files or null. * @param string $file * @param string|array $realm * @return string */ public static function findFile($file, $realm = Config::REALM_CONFIGS, $returnFirst = false) { $prefix = Config::DEFAULT_PREFIX; $files = array($prefix => array()); $paths = is_array($realm) ? $realm : Config::getPaths($realm); foreach ($paths as $path) { if (strstr($path, Config::PREFIX_SEPARATOR) !== false) { list($path, $prefix) = explode(Config::PREFIX_SEPARATOR, $path); if (!isset($files[$prefix])) { $files[$prefix] = array(); } } else { $prefix = '_'; } $filePath = substr($file, 0, 1) == DIRECTORY_SEPARATOR ? $file : $path . $file; if (file_exists($filePath)) { if ($returnFirst) { return $filePath; } $files[$prefix][] = $filePath; } } return count($files) > 0 ? $files : false; }