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


PHP Fuel::set方法代码示例

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


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

示例1: wire

 /**
  * Get or inject a ProcessWire API variable
  *
  * 1. As a getter (option 1):
  * ==========================
  * Usage: $this->wire('name'); // name is an API variable name
  * If 'name' does not exist, a WireException will be thrown.
  * Specify '*' or 'all' for name to retrieve all API vars (as a Fuel object)
  *
  * 2. As a getter (option 2):
  * ==========================
  * Usage: $this->wire()->name; // name is an API variable name
  * Null will be returned if API var does not exist (no Exception thrown).
  *
  * 3. As a setter:
  * ===============
  * $this->wire('name', $value);
  * $this->wire('name', $value, true); // lock the API variable so nothing else can overwrite it
  * $this->wire()->set('name', $value);
  * $this->wire()->set('name', $value, true); // lock the API variable so nothing else can overwrite it
  *
  * 4. As a dependency injector (PW 3.0 only)
  * =========================================
  * $this->wire(new Page());
  * When creating a new object, this makes it inject the current PW instance into that object.
  *
  * @param string|object $name Name of API variable to retrieve, set, or omit to retrieve the master ProcessWire object
  * @param null|mixed $value Value to set if using this as a setter, otherwise omit.
  * @param bool $lock When using as a setter, specify true if you want to lock the value from future changes (default=false)
  * @return ProcessWire|Wire|Session|Page|Pages|Modules|User|Users|Roles|Permissions|Templates|Fields|Fieldtypes|Sanitizer|Config|Notices|WireDatabasePDO|WireInput|string|mixed
  * @throws WireException
  *
  *
  */
 public function wire($name = '', $value = null, $lock = false)
 {
     if (is_null(self::$fuel)) {
         self::$fuel = new Fuel();
     }
     if ($value !== null) {
         // setting a fuel value
         return self::$fuel->set($name, $value, $lock);
     }
     if (empty($name)) {
         // return ProcessWire instance
         return self::$fuel->wire;
     } else {
         if ($name === '*' || $name === 'all') {
             // return Fuel instance
             return self::$fuel;
         }
     }
     /* TBA PW3
     		if(is_object($name)) {
     			// injecting ProcessWire instance to object
     			if($name instanceof Wire) return $name->setWire($this->_wire); // inject fuel, PW 3.0 
     			throw new WireException("Expected Wire instance");
     		}
     		*/
     // get API variable
     $value = self::$fuel->{$name};
     return $value;
 }
开发者ID:ryancramerdesign,项目名称:ProcessWire,代码行数:63,代码来源:Wire.php


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