Пример #1
0
 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);
 }
Пример #2
0
 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;
 }
Пример #3
0
 /**
  * Add all mandatory paths to configuration
  */
 public static function preInit()
 {
     /* add application & t41 config files path (in first position if none was declared before) */
     Config::addPath(self::$basePath . 'application/configs/', Config::REALM_CONFIGS);
     Config::addPath(self::$basePath . 'vendor/quatrain/t41/configs/', Config::REALM_CONFIGS);
     /* add templates folder path (in first position if none was declared before) */
     Config::addPath(self::$basePath . 'application/views/', Config::REALM_TEMPLATES);
     /* add t41 & application controllers paths (in first position if none was declared before) */
     Config::addPath(self::$basePath . 'application/controllers/', Config::REALM_CONTROLLERS, null, 'default');
     Config::addPath(self::$basePath . 'vendor/quatrain/t41/controllers/', Config::REALM_CONTROLLERS, null, 't41');
     /* register default REST controllers path */
     /* @todo allow override in config file or even later */
     Config::addPath(self::$basePath . 'vendor/quatrain/t41/controllers/rest/', Config::REALM_CONTROLLERS, null, 'rest');
     /* register default path where to find view objects decorators */
     Decorator::addPath(self::$basePath . 'vendor/quatrain/t41/library/t41');
     // without 'View'
 }
Пример #4
0
 public static function bind(array $config, $path, Layout\Menu $menu = null)
 {
     $store = $config['enabled'] == true ? 'enabled' : 'disabled';
     if ($store == 'disabled') {
         return;
     }
     Config::addPath($path . '/configs/', Config::REALM_CONFIGS);
     // if modules has model, declare path to the autoloader
     if (is_dir($path . '/models') && isset($config['namespace'])) {
         Core::addAutoloaderPrefix($config['namespace'], $path . '/models/');
         Config::addPath($path . '/models', Config::REALM_OBJECTS, null, $config['namespace']);
     }
     // Register views directory if it exists
     if (is_dir($path . '/views')) {
         //	Config::addPath($path . '/views', Config::REALM_TEMPLATES, Config::POSITION_TOP);
     }
 }
Пример #5
0
 /**
  * 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;
 }