当前位置: 首页>>代码示例>>PHP>>正文


PHP Package::get_file方法代码示例

本文整理汇总了PHP中Package::get_file方法的典型用法代码示例。如果您正苦于以下问题:PHP Package::get_file方法的具体用法?PHP Package::get_file怎么用?PHP Package::get_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Package的用法示例。


在下文中一共展示了Package::get_file方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: load

 public static function load($file, $cache = 3600)
 {
     if ($cache > 0 && RUN_MODE == 'deploy') {
         import('system/bin/cache');
         $cache_instance = CacheBackend::get_instance();
         $cache_id = 'yaml_' . str_replace(array('/', '.'), '_', $file);
         if ($cache_instance->is_cached($cache_id)) {
             return $cache_instance->get($cache_id);
         } else {
             if (!is_file($file)) {
                 $file = Package::get_file($file);
                 if (!is_file($file)) {
                     return array();
                 }
             }
             import('system/vendors/spyc/spyc');
             $info = spyc_load_file($file);
             $cache_instance->set($cache_id, $info);
             return $info;
         }
     }
     if (!is_file($file)) {
         $file = Package::get_file($file);
         if (!is_file($file)) {
             return array();
         }
     }
     import('system/vendors/spyc/spyc');
     $info = spyc_load_file($file);
     return $info;
 }
开发者ID:uwitec,项目名称:mgoa,代码行数:31,代码来源:yaml.php

示例2: load

 public static function load($path, $type = 'js', $extra = null)
 {
     $media_url = ini('base/MEDIA_URL');
     $file = Package::get_file('statics/' . $path, $type);
     if (is_file($file)) {
         return sprintf(self::$elements[$type], $media_url . $path, $extra);
     }
 }
开发者ID:uwitec,项目名称:mgoa,代码行数:8,代码来源:statics.php

示例3: __construct

 public function __construct($code = '', $message = '', $previous = '')
 {
     BaseConfig::load(Package::get_file('system/config/exception.yml'));
     $this->exception_messages = ini('exception/messages');
     if ($this->exception_messages[$code]) {
         $message = '(' . $code . ') ' . sprintf(_($this->exception_messages[$code]), $message);
     }
     $this->message = $message;
     $this->code = $code;
 }
开发者ID:uwitec,项目名称:mgoa,代码行数:10,代码来源:BaseException.php

示例4: __load__mongo_model__

 protected function __load__mongo_model__($model)
 {
     import('system/bin/mongo');
     list($model_path, $model_name) = explode('.', $model);
     import('applications/' . $model_path . '/mongo_models/' . $model_name);
     BaseConfig::load(Package::get_file('etc/conf.d/database.yml'));
     $dbinfo = ini('database/mongo_' . RUN_MODE);
     call_user_func(array($model_name, 'setup'), $dbinfo);
     //        $model_name::setup($dbinfo);
 }
开发者ID:uwitec,项目名称:mgoa,代码行数:10,代码来源:application.php

示例5: syncdb

 public static function syncdb($apps = null, $drop_database = false, $append = true)
 {
     if (!self::$inited || !self::$connections) {
         self::init();
     }
     if (!$apps) {
         $apps = ini('base/INSTALLED_APPS');
     }
     if (!$apps) {
         return true;
     }
     if ($drop_database) {
         Doctrine_Core::dropDatabases();
         Doctrine_Core::createDatabases();
     }
     foreach ((array) $apps as $k => $app) {
         $app = str_replace('.', '/', $app);
         try {
             /*
              * Generate the models
              */
             if (isset($_GET['use_yaml'])) {
                 $schemas = Package::get_file(sprintf('applications/%s/%s', $app, 'schemas.yml'));
                 if (!is_file($schemas)) {
                     continue;
                 }
                 Doctrine_Core::generateModelsFromYaml($schemas, Package::get_folder(sprintf('applications/%s/models', $app)), self::$_generate_options);
             } else {
                 try {
                     import(sprintf('applications/%s/models/generated/*', $app));
                 } catch (DoesNotExistsException $e) {
                     continue;
                 }
             }
             /*
              * syncdb
              */
             Doctrine_Core::createTablesFromModels(Package::get_folder(sprintf('applications/%s/models', $app)), self::$_generate_options);
             /*
              * Insert test data
              */
             $dir = Package::get_folder(sprintf('applications/%s/fixtures', $app));
             if (is_dir($dir)) {
                 Doctrine_Core::loadData($dir, $append);
             }
         } catch (PDOException $e) {
             continue;
         }
     }
 }
开发者ID:uwitec,项目名称:mgoa,代码行数:50,代码来源:doctrine.php

示例6: get_apps_config

 public static function get_apps_config($apps)
 {
     foreach ($apps as $app) {
         $file = Package::get_file(sprintf('applications/%s/config.yml', $app));
         if (!is_file($file)) {
             continue;
         }
         /*
          * get the applications's config
          */
         $app_config = self::$config['apps_configs'][$app];
         if (!$app_config) {
             $app_config = YamlBackend::load($file);
             self::$config['apps_configs'][$app] = $app_config;
         }
     }
     return self::$config['apps_configs'];
 }
开发者ID:uwitec,项目名称:mgoa,代码行数:18,代码来源:base.php

示例7: trigger

 public static function trigger()
 {
     if (!self::$inited and ini('runtime/application_instance') instanceof BaseApplication) {
         self::init(ini('runtime/application_instance'));
     }
     list($hook_name, $params) = func_get_args();
     $params = (array) $params;
     if (!$hook_name || !key_exists($hook_name, self::$hooks)) {
         return false;
     }
     if ($hook_name == 'before_template_render') {
     }
     foreach ((array) self::$hooks[$hook_name] as $k => $v) {
         if (!is_callable(array($v['class'], $v['method']))) {
             $file = Package::get_file($v['file']);
             if (!is_file($file)) {
                 continue;
             }
             import($file);
         }
         array_unshift($params, self::$application);
         if (is_callable(array($v['class'], $v['method']))) {
             $result = call_user_func_array(array($v['class'], $v['method']), $params);
             /*
              * Call the callback function
              */
             if ($params['callback']) {
                 $result = call_user_func_array($params['callback'], (array) $result);
             }
         }
     }
 }
开发者ID:uwitec,项目名称:mgoa,代码行数:32,代码来源:base.php

示例8: dispatch

 public static function dispatch($app, $view_action, array $params = null)
 {
     $view_action = $view_action ? $view_action : 'index';
     import('system/bin/application');
     import('system/bin/cache');
     /*
      * application's url pattern mapping
      */
     $app_map_array = YamlBackend::load('etc/conf.d/urls.yml');
     if ($app_map_array['map'][$app]) {
         $app = $app_map_array['map'][$app];
     } else {
         if (array_keys($app_map_array['map'], $app)) {
             throw new DispatchException(1011, $app . '/' . $view_action);
         }
     }
     /*
      * Cache all INSTALLED APPS urls pattern
      */
     $cache_id = 'URLS_MAP';
     $url_name_map_cache_id = 'URL_NAME_MAP';
     $app_map_array_flip_cache_id = 'URL_APP_MAP_ARRAY_FLIP';
     $cache_instance = CacheBackend::get_instance();
     if ($cache_instance->is_cached($cache_id) && RUN_MODE == 'deploy' && false) {
         self::$url_patterns = $cache_instance->get($cache_id);
         self::$url_name_map = $cache_instance->get($url_name_map_cache_id);
         $app_map_array_flip = $cache_instance->get($app_map_array_flip_cache_id);
     } else {
         $installed_apps = ini('base/INSTALLED_APPS');
         $app_map_array_flip = array_flip($app_map_array['map']);
         foreach ($installed_apps as $installed_app) {
             $urlpattern = YamlBackend::load(sprintf('applications/%s/urls.yml', $installed_app));
             if ($app_map_array_flip[$installed_app]) {
                 $installed_app = $app_map_array_flip[$installed_app];
             }
             /*
              * The url-name map to view action
              * like: url name='auth_login' => auth.AuthController.login
              */
             if ($urlpattern) {
                 foreach ($urlpattern as $key => $value) {
                     if ($value['name']) {
                         self::$url_name_map[$value['name']] = $installed_app . '/' . $key;
                     }
                 }
             }
             self::$url_patterns[$installed_app] = $urlpattern;
         }
         $cache_instance->set($cache_id, self::$url_patterns);
         if (self::$url_name_map) {
             $cache_instance->set($url_name_map_cache_id, self::$url_name_map);
         }
         $cache_instance->set($app_map_array_flip_cache_id, $app_map_array_flip);
     }
     $app_map_name = array_key_exists($app, $app_map_array_flip) ? $app_map_array_flip[$app] : $app;
     $urlpattern = self::$url_patterns[$app_map_name];
     try {
         /*
          * does not set the action key
          */
         if (!$urlpattern[$view_action]['action']) {
             $_c = ucfirst($app) . 'Controller';
             try {
                 import(Package::get_file(sprintf('applications/%s/%s', $app, $_c)));
                 $urlpattern[$view_action]['action'] = $_c . '.' . $view_action;
             } catch (DoesNotExistsException $e) {
                 throw new DispatchException(1011, $app . '/' . $view_action);
             }
         }
         list($controller, $method) = explode('.', $urlpattern[$view_action]['action']);
         import(sprintf('applications/%s/%s', $app, $controller));
         if (!is_callable(array($controller, $method))) {
             throw new DispatchException(1011, $app . '/' . $view_action);
         }
         /*
          * Set current application and action
          */
         RuntimeConfig::set('runtime/application', $app);
         RuntimeConfig::set('runtime/action', $view_action);
         RuntimeConfig::set('runtime/view_action', $app . '/' . $view_action);
         BaseConfig::load_application_config($app);
         try {
             $controller = new $controller($params);
             RuntimeConfig::set('runtime/application_instance', $controller);
             /*
              * Re-init the plugins with the application implements
              */
             Pluggable::init($controller);
             /*
              * Trigger the plugins in before_application_run
              */
             Pluggable::trigger('before_application_run');
             /*
              * Call the view-action method
              */
             call_user_func_array(array($controller, $method), (array) $params);
             /*
              * Dependence exception
              */
         } catch (DependenceException $e) {
//.........这里部分代码省略.........
开发者ID:uwitec,项目名称:mgoa,代码行数:101,代码来源:base.php

示例9: get_template_real_path

 public function get_template_real_path($template)
 {
     $installed_apps = ini('base/INSTALLED_APPS');
     $tpl = Package::get_file('applications/' . ini('runtime/application') . '/templates/' . $template, 'tpl');
     if (!is_file($tpl)) {
         foreach ($installed_apps as $app) {
             $file = Package::get_file(sprintf('applications/%s/templates/%s', $app, $template), 'tpl');
             if (is_file($file)) {
                 $finded = true;
                 $tpl = $file;
                 break;
             }
         }
         if (!$finded) {
             $tpl = Package::get_file('var/templates/' . $template, 'tpl');
         }
     }
     if (!is_file($tpl)) {
         throw new DoesNotExistsException(1008, $tpl);
     }
     return $tpl;
 }
开发者ID:uwitec,项目名称:mgoa,代码行数:22,代码来源:smarty.php

示例10: write

 public static function write($path, $content, $ext = 'php')
 {
     $path = Package::get_file($path, $ext);
     return @file_put_contents($path, $content);
 }
开发者ID:uwitec,项目名称:mgoa,代码行数:5,代码来源:filesystem.php


注:本文中的Package::get_file方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。