當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Wire::fuel方法代碼示例

本文整理匯總了PHP中Wire::fuel方法的典型用法代碼示例。如果您正苦於以下問題:PHP Wire::fuel方法的具體用法?PHP Wire::fuel怎麽用?PHP Wire::fuel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Wire的用法示例。


在下文中一共展示了Wire::fuel方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: setFuel

 /**
  * Add fuel to all classes descending from Wire
  *
  * @param string $name 
  * @param mixed $value 
  *
  */
 public static function setFuel($name, $value)
 {
     if (is_null(self::$fuel)) {
         self::$fuel = new Fuel();
     }
     self::$fuel->set($name, $value);
 }
開發者ID:ryancramerdesign,項目名稱:ProcessWire-2.0,代碼行數:14,代碼來源:Wire.php

示例2: 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.
  * 
  * 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
  * 
  * @param string $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 mixed|ProcessWire
  * @throws WireException
  * 
  *
  */
 public function wire($name = '', $value = null, $lock = false)
 {
     if (is_null(self::$fuel)) {
         self::$fuel = new Fuel();
     }
     if (!is_null($value)) {
         return self::$fuel->set($name, $value, $lock);
     }
     if (empty($name)) {
         return self::$fuel->wire;
     }
     $value = self::$fuel->{$name};
     //if(is_null($value)) throw new WireException("Unknown API variable: $name");
     return $value;
 }
開發者ID:avatar382,項目名稱:fablab_site,代碼行數:43,代碼來源:Wire.php

示例3: 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


注:本文中的Wire::fuel方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。