load() public method

public load ( $key )
示例#1
0
 /**
  * 应用程序初始化
  */
 public static function start()
 {
     // 注册AUTOLOAD方法
     spl_autoload_register('Think\\Think::autoLoad');
     // 设定错误和异常处理
     register_shutdown_function('Think\\Think::fatalError');
     set_error_handler('Think\\Think::appError');
     set_exception_handler('Think\\Think::appException');
     // 初始化文件存储方式
     Storage::connect(STORAGE_TYPE);
     $runtimeFile = RUNTIME_PATH . APP_MODE . '~runtime.php';
     if (!APP_DEBUG && Storage::has($runtimeFile)) {
         Storage::load($runtimeFile);
     } else {
         $content = '';
         // 读取应用模式
         $mode = (include is_file(CONF_PATH . 'core.php') ? CONF_PATH . 'core.php' : MODE_PATH . APP_MODE . '.php');
         // 加载核心文件
         foreach ($mode['core'] as $file) {
             if (is_file($file)) {
                 include $file;
                 if (!APP_DEBUG) {
                     $content .= compile($file);
                 }
             }
         }
         // 加载应用模式配置文件
         foreach ($mode['config'] as $key => $file) {
             is_numeric($key) ? C(load_config($file)) : C($key, load_config($file));
         }
     }
 }
示例#2
0
文件: Think.class.php 项目: dlpc/shop
 /**
  * 应用程序初始化
  * @access public
  * @return void
  */
 public static function start()
 {
     // 注册AUTOLOAD方法
     spl_autoload_register('Think\\Think::autoload');
     // 设定错误和异常处理
     register_shutdown_function('Think\\Think::fatalError');
     set_error_handler('Think\\Think::appError');
     set_exception_handler('Think\\Think::appException');
     // 初始化文件存储方式
     Storage::connect(STORAGE_TYPE);
     $runtimefile = RUNTIME_PATH . APP_MODE . '~runtime.php';
     if (!APP_DEBUG && Storage::has($runtimefile)) {
         Storage::load($runtimefile);
     } else {
         if (Storage::has($runtimefile)) {
             Storage::unlink($runtimefile);
         }
         $content = '';
         // 读取应用模式
         $mode = (include is_file(CONF_PATH . 'core.php') ? CONF_PATH . 'core.php' : MODE_PATH . APP_MODE . '.php');
         // 加载核心文件
         foreach ($mode['core'] as $file) {
             if (is_file($file)) {
                 include $file;
                 if (!APP_DEBUG) {
                     $content .= compile($file);
                 }
             }
         }
         // 加载应用模式配置文件
         foreach ($mode['config'] as $key => $file) {
             is_numeric($key) ? C(include $file) : C($key, include $file);
         }
         // 读取当前应用模式对应的配置文件
         if ('common' != APP_MODE && is_file(CONF_PATH . 'config_' . APP_MODE . '.php')) {
             C(include CONF_PATH . 'config_' . APP_MODE . '.php');
         }
         // 加载模式别名定义
         if (isset($mode['alias'])) {
             self::addMap(is_array($mode['alias']) ? $mode['alias'] : (include $mode['alias']));
         }
         // 加载应用别名定义文件
         if (is_file(CONF_PATH . 'alias.php')) {
             self::addMap(include CONF_PATH . 'alias.php');
         }
         // 加载模式行为定义
         if (isset($mode['tags'])) {
             Hook::import(is_array($mode['tags']) ? $mode['tags'] : (include $mode['tags']));
         }
         // 加载应用行为定义
         if (is_file(CONF_PATH . 'tags.php')) {
             // 允许应用增加开发模式配置定义
             Hook::import(include CONF_PATH . 'tags.php');
         }
         // 加载框架底层语言包
         L(include THINK_PATH . 'Lang/' . strtolower(C('DEFAULT_LANG')) . '.php');
         if (!APP_DEBUG) {
             $content .= "\nnamespace { Think\\Think::addMap(" . var_export(self::$_map, true) . ");";
             $content .= "\nL(" . var_export(L(), true) . ");\nC(" . var_export(C(), true) . ');Think\\Hook::import(' . var_export(Hook::get(), true) . ');}';
             Storage::put($runtimefile, strip_whitespace('<?php ' . $content));
         } else {
             // 调试模式加载系统默认的配置文件
             C(include THINK_PATH . 'Conf/debug.php');
             // 读取应用调试配置文件
             if (is_file(CONF_PATH . 'debug.php')) {
                 C(include CONF_PATH . 'debug.php');
             }
         }
     }
     // 读取当前应用状态对应的配置文件
     if (APP_STATUS && is_file(CONF_PATH . APP_STATUS . '.php')) {
         C(include CONF_PATH . APP_STATUS . '.php');
     }
     // 设置系统时区
     date_default_timezone_set(C('DEFAULT_TIMEZONE'));
     // 检查应用目录结构 如果不存在则自动创建
     if (C('CHECK_APP_DIR') && !is_dir(LOG_PATH)) {
         // 创建应用目录结构
         require THINK_PATH . 'Common/build.php';
     }
     // 记录加载文件时间
     G('loadTime');
     // 运行应用
     App::run();
 }
 /**
  * 加载模板
  * @access public
  * @param string $tmplTemplateFile 模板文件
  * @param array  $templateVar 模板变量
  * @param string $prefix 模板标识前缀
  * @return void
  */
 public function fetch($templateFile, $templateVar, $prefix = '')
 {
     $this->tVar = $templateVar;
     $templateCacheFile = $this->loadTemplate($templateFile, $prefix);
     Storage::load($templateCacheFile, $this->tVar, null, 'tpl');
 }
示例#4
0
 protected function _actionDeleteSample()
 {
     $key = $_GET['key'];
     if (!empty($key)) {
         $storage = new Storage($this->_globalVar['config']['storage']);
         $job = $storage->load($key);
         if ($job) {
             $storage->delete($key);
         }
     }
     header('Location: index.php?action=manageSamples');
     exit;
 }
示例#5
0
  * @param string $content 模板输出内容
  * @param string $prefix 模板缓存前缀
  * @return mixed
  */
 public function display($templateFile = '', $charset = '', $contentType = '', $content = '', $prefix = '')
 {
     G('viewStartTime');
     // 解析并获取模板内容
     $content = $this->fetch($templateFile, $content, $prefix);
     // 输出模板内容
     $this->render($content, $charset, $contentType);
 }
 /**
  * 输出内容文本可以包括Html
  * @access private
  * @param string $content 输出内容
  * @param string $charset 模板输出字符集
  * @param string $contentType 输出类型
  * @return mixed
  */
 private function render($content, $charset = '', $contentType = '')
 {
     if (empty($charset)) {
         $charset = C('DEFAULT_CHARSET');
     }
     if (empty($contentType)) {
         $contentType = C('TMPL_CONTENT_TYPE');
     }
     // 网页字符编码
     header('Content-Type:' . $contentType . '; charset=' . $charset);
     header('Cache-control: ' . C('HTTP_CACHE_CONTROL'));
     // 页面缓存控制
     header('X-Powered-By:ThinkPHP');
     // 输出模板文件
     echo $content;
 }
 /**
  * 解析和获取模板内容 用于输出
  * @access public
  * @param string $templateFile 模板文件名
  * @param string $content 模板输出内容
  * @param string $prefix 模板缓存前缀
  * @return string
  */
 public function fetch($templateFile = '', $content = '', $prefix = '')
 {
     if (empty($content)) {
         $templateFile = $this->parseTemplate($templateFile);
         // 模板文件不存在直接返回
示例#6
0
 protected function setUp()
 {
     $this->_model = new Storage($this->getMockBuilder('Magento\\Customer\\Model\\Resource\\Customer\\CollectionFactory')->disableOriginalConstructor()->getMock(), $this->getMockBuilder('Magento\\ImportExport\\Model\\Resource\\CollectionByPagesIteratorFactory')->disableOriginalConstructor()->getMock(), $this->_getModelDependencies());
     $this->_model->load();
 }
示例#7
0
 /**
  * 应用程序初始化
  * @access public
  * @return void
  */
 public static function start()
 {
     // 设定错误和异常处理
     register_shutdown_function('Think\\Think::fatalError');
     set_error_handler('Think\\Think::appError');
     set_exception_handler('Think\\Think::appException');
     // 注册AUTOLOAD方法
     spl_autoload_register('Think\\Think::autoload');
     // 初始化文件存储方式
     Storage::connect(STORAGE_TYPE);
     $runtimefile = RUNTIME_PATH . APP_MODE . '~runtime.php';
     if (!APP_DEBUG && Storage::has($runtimefile, 'runtime')) {
         Storage::load($runtimefile, null, 'runtime');
     } else {
         if (Storage::has($runtimefile, 'runtime')) {
             Storage::unlink($runtimefile, 'runtime');
         }
         $content = '';
         // 读取应用模式
         $mode = (include is_file(COMMON_PATH . 'Conf/core.php') ? COMMON_PATH . 'Conf/core.php' : THINK_PATH . 'Conf/Mode/' . APP_MODE . '.php');
         // 加载核心文件
         foreach ($mode['core'] as $file) {
             if (is_file($file)) {
                 include $file;
                 if (!APP_DEBUG) {
                     $content .= compile($file);
                 }
             }
         }
         // 加载配置文件
         foreach ($mode['config'] as $key => $file) {
             is_numeric($key) ? C(include $file) : C($key, include $file);
         }
         // 加载别名定义
         foreach ($mode['alias'] as $alias) {
             self::addMap(is_array($alias) ? $alias : (file_exists($alias) ? include $alias : array()));
         }
         // 加载模式系统行为定义
         if (isset($mode['extends'])) {
             Hook::import(is_array($mode['extends']) ? $mode['extends'] : (include $mode['extends']));
         }
         // 加载应用行为定义
         if (isset($mode['tags'])) {
             if (is_array($mode['tags'])) {
                 $tags = $mode['tags'];
             } else {
                 $tags = file_exists($mode['tags']) ? include $mode['tags'] : array();
             }
             Hook::import($tags);
         }
         // 加载框架底层语言包
         L(include THINK_PATH . 'Lang/' . strtolower(C('DEFAULT_LANG')) . '.php');
         if (!APP_DEBUG) {
             $content .= "\nnamespace { Think\\Think::addMap(" . var_export(self::$_map, true) . ");";
             $content .= "\nL(" . var_export(L(), true) . ");\nC(" . var_export(C(), true) . ');Think\\Hook::import(' . var_export(Hook::get(), true) . ');}';
             Storage::put($runtimefile, strip_whitespace('<?php ' . $content), 'runtime');
         } else {
             // 调试模式加载系统默认的配置文件
             C(include THINK_PATH . 'Conf/debug.php');
             // 读取调试模式的应用状态
             $status = C('APP_STATUS');
             // 加载对应的项目配置文件
             if (is_file(COMMON_PATH . 'Conf/' . $status . '.php')) {
                 // 允许项目增加开发模式配置定义
                 C(include COMMON_PATH . 'Conf/' . $status . '.php');
             }
         }
     }
     // 设置系统时区
     date_default_timezone_set(C('DEFAULT_TIMEZONE'));
     // 检查项目目录结构 如果不存在则自动创建
     if (C('CHECK_APP_DIR') && !is_dir(LOG_PATH)) {
         // 创建项目目录结构
         require THINK_PATH . 'Common/build.php';
     }
     // 记录加载文件时间
     G('loadTime');
     if (!defined('IsInterface')) {
         // 运行应用
         App::run();
     } else {
         App::init();
     }
 }
示例#8
0
 public function load(&$data = null)
 {
     parent::load($this->data);
 }