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


PHP config::getList方法代码示例

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


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

示例1: getDefinition

 /**
  * Reads mapping definition of selected data set into runtime and prepares
  * it for improved mapping operation.
  *
  * @param string $setName name of data set to be mapped
  * @param boolean $forward true to get forward mapping, false to get reverse mapping
  * @return array mapping of names for selected data set in desired direction
  * @throws \InvalidArgumentException on using invalid name data set
  */
 protected static function getDefinition($setName, $forward)
 {
     if (!array_key_exists($setName, static::$_mappings)) {
         if (!preg_match('/^([a-z][a-z0-9_]+)(\\.([a-z][a-z0-9_]+))*$/i', $setName)) {
             throw new \InvalidArgumentException('invalid set name');
         }
         static::$_mappings[$setName] = array('forward' => array(), 'backward' => array());
         foreach (config::getList('mappings.' . $setName . '.map') as $def) {
             if (is_array($def)) {
                 $from = trim(@$def['from']);
                 $to = trim(@$def['to']);
                 $drop = !!@$def['drop'] || $to === '';
                 static::$_mappings[$setName]['forward'][$from] = $drop ? null : $to;
                 if ($drop) {
                     static::$_mappings[$setName]['backward'][$to] = $from;
                 }
             }
         }
         unset($definition);
     }
     return $forward ? static::$_mappings[$setName]['forward'] : static::$_mappings[$setName]['backward'];
 }
开发者ID:cepharum,项目名称:txf,代码行数:31,代码来源:name_mapping.php

示例2: findProvider

 /**
  * Iterates over given or configured list of user database providers invoking
  * provided callback on every provider until first callback is returning
  * properly without throwing exception.
  *
  * @param callable $callback callback to invoke per iterated user database provider
  * @param array|string $explicitSource set of provider names to iterate or name of first provider in a sequence to test
  * @return mixed|null result return from callback, null if all callbacks threw exception
  * @throws \RuntimeException on missing valid set of providers to iterate
  * @throws unauthorized_exception if callback is throwing in other case than "user isn't found"
  * @throws \InvalidArgumentException on missing callback
  */
 public static final function findProvider($callback, $explicitSource = null)
 {
     if (!is_callable($callback)) {
         throw new \InvalidArgumentException('invalid callback on finding user provider');
     }
     // get list of sources to look up for requested user
     if (is_array($explicitSource)) {
         $sources = $explicitSource;
     } else {
         $sources = func_get_args();
         array_shift($sources);
     }
     if (!count($sources)) {
         $sources = config::getList('user.sources.enabled');
     }
     if (!count($sources)) {
         throw new \RuntimeException('missing/invalid user sources configuration');
     }
     // traverse list of sources ...
     foreach ($sources as $source) {
         if (trim($source) !== '' && ctype_alnum($source)) {
             // read its configuration
             $definition = config::get('user.sources.setup.' . $source);
             if (is_array($definition)) {
                 // read name of class for managing user source from configuration
                 $class = array_key_exists('class', $definition) ? data::isKeyword($definition['class']) : null;
                 if (!$class) {
                     $class = data::isKeyword($definition['type'] . '_user');
                 }
                 if (txf::import($class)) {
                     try {
                         // create instance of managing class
                         $factory = new \ReflectionClass($class);
                         $user = $factory->newInstance();
                         if ($user instanceof self) {
                             $user->configure($definition);
                             return call_user_func($callback, $user);
                         }
                     } catch (unauthorized_exception $e) {
                         if (!$e->isUserNotFound()) {
                             throw $e;
                         }
                     } catch (\Exception $e) {
                         log::warning('failed to search user source: ' . $e);
                     }
                 }
             }
         }
     }
     return null;
 }
开发者ID:cepharum,项目名称:txf,代码行数:63,代码来源:user.php

示例3: getCode

 /**
  * Renders pager widget.
  *
  * @return string code describing pager widget
  */
 public function getCode()
 {
     if (!$this->isEnabled()) {
         return '';
     }
     $size = $this->size();
     $offset = $this->offset();
     // compile data to use on rendering pager
     $setup = array('sizeName' => $this->sizeName, 'offsetName' => $this->offsetName, 'itemCount' => $this->itemCount, 'pageOffsets' => array(), 'sizes' => config::getList('pager.size.option', array(10, 20, 50, 100)), 'size' => $size, 'offset' => $offset, 'useButtons' => $this->useButtons);
     for ($i = $offset; $i > -$size; $i -= $size) {
         array_unshift($setup['pageOffsets'], max(0, $i));
     }
     $setup['currentPage'] = count($setup['pageOffsets']) - 1;
     for ($i = $offset + $size; $i < $this->itemCount; $i += $size) {
         array_push($setup['pageOffsets'], min($this->itemCount - ($this->showFullFinalPage() ? $size : 1), $i));
     }
     // render pager using template
     return view::render('widgets/pager', $setup);
 }
开发者ID:cepharum,项目名称:txf,代码行数:24,代码来源:pager.php

示例4: initializeClassRedirections

 /**
  * Initializes support for class redirections by reading initial map from
  * runtime configuration.
  */
 protected function initializeClassRedirections()
 {
     $initialRedirections = config::getList('txf.autoloader.redirect');
     if (is_array($initialRedirections)) {
         foreach ($initialRedirections as $redirection) {
             try {
                 $this->redirectClass($redirection['source'], $redirection['target']);
             } catch (\InvalidArgumentException $e) {
                 trigger_error(sprintf('invalid class redirection %s -> %s ignored', $redirection['source'], $redirection['target']), E_USER_WARNING);
             }
         }
     }
 }
开发者ID:cepharum,项目名称:txf,代码行数:17,代码来源:txf.php

示例5: getLinks

 /**
  * Ensures to read set of connection definitions from configuration.
  *
  * This method is prefetching all named datasource definitions from current
  * configuration. A named datasource link (here called "customlink") is
  * defined like this:
  *
  * <datasource>
  *  <link>
  *   <id>customlink</id>
  *   <dsn>DSN of my datasource</dsn>
  *   <user>myloginname</user>
  *   <password>mysecretpassword</password>
  *  </link>
  * </datasource>
  */
 protected static function getLinks()
 {
     if (!is_array(self::$definitions)) {
         self::$definitions = array();
         // load all properly named datasource configurations
         foreach (config::getList('datasource.link') as $link) {
             if (is_array($link) && trim(@$link['id']) !== '') {
                 self::$definitions[trim($link['id'])] = $link;
             }
         }
     }
     return self::$definitions;
 }
开发者ID:cepharum,项目名称:txf,代码行数:29,代码来源:datasource.php


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