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


PHP Kohana::key_string方法代码示例

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


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

示例1: get

 /**
  * Gets a value from config. If required is TRUE
  * then get will throw an exception if value cannot
  * be loaded.
  *
  * @param   string       key  the setting to get
  * @param   bool         slash  remove trailing slashes
  * @param   bool         required  is setting required?
  * @return  mixed
  * @access  public
  */
 public function get($key, $slash = FALSE, $required = FALSE)
 {
     // Get the group name from the key
     $group = explode('.', $key, 2);
     $group = $group[0];
     // Check for existing value and load it dynamically if required
     if (!isset($this->config[$group])) {
         $this->config[$group] = $this->load($group, $required);
     }
     // Get the value of the key string
     $value = Kohana::key_string($this->config, $key);
     if ($slash === TRUE and is_string($value) and $value !== '') {
         // Force the value to end with "/"
         $value = rtrim($value, '/') . '/';
     }
     if ($required === TRUE and $value === null) {
         throw new Kohana_Config_Exception('Value not found in config driver');
     }
     $this->loaded = TRUE;
     return $value;
 }
开发者ID:JasonWiki,项目名称:docs,代码行数:32,代码来源:Config.php

示例2: get

 /**
  * Get a variable. Access to sub-arrays is supported with key.subkey.
  *
  * @param   string  variable key
  * @param   mixed   default value returned if variable does not exist
  * @return  mixed   Variable data if key specified, otherwise array containing all session data.
  */
 public function get($key = FALSE, $default = FALSE)
 {
     if (empty($key)) {
         return $_SESSION;
     }
     $result = isset($_SESSION[$key]) ? $_SESSION[$key] : Kohana::key_string($_SESSION, $key);
     return $result === NULL ? $default : $result;
 }
开发者ID:Toushi,项目名称:flow,代码行数:15,代码来源:Session.php

示例3: message

 /**
  * Fetch a message item.
  *
  * @param   string  language key to fetch
  * @param   array   additional information to insert into the line
  * @return  string  i18n language string, or the requested key if the i18n item is not found
  */
 public static function message($key, $args = array())
 {
     // Extract the main group from the key
     $group = explode('.', $key, 2);
     $group = $group[0];
     if (!isset(Kohana::$internal_cache['messages'][$group])) {
         // Messages for this group
         $messages = array();
         if ($file = Kohana::find_file('messages', $group)) {
             include $file[0];
         }
         if (!isset(Kohana::$write_cache['messages'])) {
             // Write language cache
             Kohana::$write_cache['messages'] = TRUE;
         }
         Kohana::$internal_cache['messages'][$group] = $messages;
     }
     // Get the line from cache
     $line = Kohana::key_string(Kohana::$internal_cache['messages'], $key);
     if ($line === NULL) {
         Kohana_Log::add('error', 'Missing messages entry ' . $key . ' for message ' . $group);
         // Return the key string as fallback
         return $key;
     }
     if (is_string($line) and func_num_args() > 1) {
         $args = array_slice(func_get_args(), 1);
         // Add the arguments into the line
         $line = vsprintf($line, is_array($args[0]) ? $args[0] : $args);
     }
     return $line;
 }
开发者ID:joericochuyt,项目名称:gallery3,代码行数:38,代码来源:Kohana.php


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