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


PHP factory::set方法代码示例

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


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

示例1: __construct

 /**
  * Constructing cache object
  *
  * @param string $cache_link
  * @param string $class
  */
 public function __construct($cache_link = null, $class = null)
 {
     // if we need to use default link from application
     if (empty($cache_link)) {
         $cache_link = application::get(['flag', 'global', 'cache', 'default_cache_link']);
         if (empty($cache_link)) {
             throw new Exception('You must specify cache link and/or class!');
         }
     }
     // get object from factory
     $temp = factory::get(['cache', $cache_link]);
     // if we have class
     if (!empty($class) && !empty($cache_link)) {
         // replaces in case we have it as submodule
         $class = str_replace('.', '_', trim($class));
         // if we are replacing database connection with the same link we
         // need to manually close connection
         if (!empty($temp['object']) && $temp['class'] != $class) {
             $object = $temp['object'];
             $object->close();
             unset($this->object);
         }
         $this->object = new $class($cache_link);
         // putting every thing into factory
         factory::set(['cache', $cache_link], ['object' => $this->object, 'class' => $class]);
     } else {
         if (!empty($temp['object'])) {
             $this->object = $temp['object'];
         } else {
             throw new Exception('You must specify cache link and/or class!');
         }
     }
 }
开发者ID:volodymyr-volynets,项目名称:framework,代码行数:39,代码来源:cache.php

示例2: __construct

 /**
  * Constructing crypt object
  *
  * @param string $db_link
  * @param string $class
  */
 public function __construct($crypt_link = null, $class = null, $options = [])
 {
     // if we need to use default link from application
     if ($crypt_link == null) {
         $crypt_link = application::get(['flag', 'global', 'crypt', 'default_crypt_link']);
         if (empty($crypt_link)) {
             throw new Exception('You must specify crypt link!');
         }
     }
     // get object from factory
     $temp = factory::get(['crypt', $crypt_link]);
     // if we have class
     if (!empty($class) && !empty($crypt_link)) {
         // replaces in case we have it as submodule
         $class = str_replace('.', '_', trim($class));
         // creating new class
         unset($this->object);
         $this->object = new $class($crypt_link, $options);
         factory::set(['crypt', $crypt_link], ['object' => $this->object, 'class' => $class]);
     } else {
         if (!empty($temp['object'])) {
             $this->object = $temp['object'];
         } else {
             throw new Exception('You must specify crypt link and/or class!');
         }
     }
 }
开发者ID:volodymyr-volynets,项目名称:framework,代码行数:33,代码来源:crypt.php

示例3: __construct

 /**
  * Constructing database object
  *
  * @param string $db_link
  * @param string $class
  */
 public function __construct($db_link = null, $class = null)
 {
     // if we need to use default link from application
     if (empty($db_link)) {
         $db_link = application::get(['flag', 'global', 'db', 'default_db_link']);
         if (empty($db_link)) {
             throw new Exception('You must specify database link and/or class!');
         }
     }
     // get object from factory
     $temp = factory::get(['db', $db_link]);
     // if we have class
     if (!empty($class) && !empty($db_link)) {
         // replaces in case we have it as submodule
         $class = str_replace('.', '_', trim($class));
         // if we are replacing database connection with the same link we
         // need to manually close database connection
         if (!empty($temp['object']) && $temp['class'] != $class) {
             $object = $temp['object'];
             $object->close();
             unset($this->object);
         }
         // creating new class
         $this->object = new $class($db_link);
         // determining ddl class & object
         $ddl_class = str_replace('_base_abc123', '_ddl', $class . '_abc123');
         $ddl_object = new $ddl_class();
         // backend
         $this->backend = str_replace(['numbers_backend_db_', '_base'], '', $class);
         // putting every thing into factory
         factory::set(['db', $db_link], ['object' => $this->object, 'class' => $class, 'backend' => $this->backend, 'ddl_class' => $ddl_class, 'ddl_object' => $ddl_object]);
     } else {
         if (!empty($temp['object'])) {
             $this->object =& $temp['object'];
             $this->backend = $temp['backend'];
         } else {
             throw new Exception('You must specify database link and/or class!');
         }
     }
 }
开发者ID:volodymyr-volynets,项目名称:framework,代码行数:46,代码来源:db.php


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