__get() public method

This method will check in the following order and act accordingly: - a property defined by a getter: return the getter result - a property of a behavior: return the behavior property value Do not call this method directly as it is a PHP magic method that will be implicitly called when executing $value = $component->property;.
See also: __set()
public __get ( string $name ) : mixed
$name string the property name
return mixed the property value or the value of a behavior's property
コード例 #1
0
 /**
  * Check whether we have a plugin installed with that name previous firing up the call
  * @param string $name
  * @return mixed|void
  */
 public function __get($name)
 {
     if (ArrayHelper::keyExists($name, $this->getInstalledPlugins())) {
         return $this->getPlugin($name);
     }
     return parent::__get($name);
 }
コード例 #2
0
ファイル: UniSender.php プロジェクト: omgdef/yii2-unisender
 /**
  * @inheritdoc
  */
 public function __get($name)
 {
     if (property_exists($this->obj, $name)) {
         return $this->obj->{$name};
     }
     return parent::__get($name);
 }
コード例 #3
0
ファイル: Wechat.php プロジェクト: kousuutetu/yii2-wechat
 protected function getValue($name)
 {
     if (isset(static::$_modules[$name])) {
         return Yii::createObject(static::$_modules[$name]);
     }
     return parent::__get($name);
 }
コード例 #4
0
 /**
  * Getter magic method.
  * This method is overridden to support accessing components like reading properties.
  * @param string $name component or property name
  * @return mixed the named property value
  */
 public function __get($name)
 {
     if ($this->has($name)) {
         return $this->get($name);
     } else {
         return parent::__get($name);
     }
 }
コード例 #5
0
ファイル: Mailchimp.php プロジェクト: bdart/yii2-mailchimp
 /**
  * @param string $name
  * @return mixed
  */
 public function __get($name)
 {
     try {
         parent::__get($name);
     } catch (\yii\base\UnknownPropertyException $e) {
         return $this->mailChimp->{$name};
     }
 }
コード例 #6
0
ファイル: Api.php プロジェクト: heartshare/yii2-uploadcare
 public function __get($name)
 {
     if (property_exists($this->_api, $name)) {
         return $this->_api->{$name};
     } else {
         return parent::__get($name);
     }
 }
コード例 #7
0
 /**
  * Getter magic method.
  * This method is overridden to support accessing components like reading properties.
  * @param string $name component or property name
  * @return mixed the named property value
  */
 public function __get($name)
 {
     // 获取component,只要定义中有,就可以拿到
     // 未实例化,get方法会去实例化
     if ($this->has($name)) {
         return $this->get($name);
     } else {
         return parent::__get($name);
     }
 }
コード例 #8
0
ファイル: SmsManager.php プロジェクト: strong2much/yii2-sms
 /**
  * Any requests to set or get attributes or call methods on this class that
  * are not found are redirected to the {@link IService} object.
  * @param string $name the attribute name
  * @return mixed
  * @throws \Exception
  */
 public function __get($name)
 {
     try {
         return parent::__get($name);
     } catch (\Exception $e) {
         if (property_exists($this->_service, $name)) {
             return $this->_service->{$name};
         } else {
             throw $e;
         }
     }
 }
コード例 #9
0
 /**
  * @param $name
  * @return \Google_Service|mixed
  */
 function __get($name)
 {
     if (!isset($this->services[$name])) {
         return parent::__get($name);
     }
     if (null === $this->serviceInstances[$name]) {
         /** @var \Google_Service $serviceClass */
         $serviceClass = $this->services[$name]["class"];
         $this->serviceInstances[$name] = new $serviceClass($this->getClient());
     }
     return $this->serviceInstances[$name];
 }
コード例 #10
0
 public function __get($name)
 {
     $property = '_' . $name;
     if (property_exists($this, $property) && $this->{$property} === null) {
         $className = '\\' . ucfirst($name);
         $this->{$property} = new $className($this->_module->account, $this->_module->password);
         return $this->{$property};
     }
     return parent::__get($name);
 }
コード例 #11
0
ファイル: IPv4.php プロジェクト: larryli/ipv4-yii2
 /**
  * @param string $name
  * @return mixed
  * @throws \yii\base\UnknownPropertyException
  */
 public function __get($name)
 {
     if (isset($this->objects[$name])) {
         return $this->objects[$name];
     }
     return parent::__get($name);
 }
コード例 #12
0
 public function __get($name)
 {
     return $this->canGetProperty($name) ? parent::__get($name) : $this->getWorker($name);
 }
コード例 #13
0
ファイル: MpWechat.php プロジェクト: ashdark/yii2-wechat-sdk
 public function __get($name)
 {
     if ($name != 'Mp' && substr($name, 0, 2) == 'Mp') {
         $className = 'ashdark\\wechat\\mp\\' . $name;
         if (class_exists($className)) {
             if (empty($this->_mp_arr[$name])) {
                 $this->_mp_arr[$name] = new $className(['mp' => $this->getMp()]);
             }
             return $this->_mp_arr[$name];
         }
     }
     return parent::__get($name);
 }
コード例 #14
0
ファイル: Connection.php プロジェクト: yii2ext/redis
 /**
  * Returns a property value based on its name.
  * Do not call this method. This is a PHP magic method that we override
  * to allow using the following syntax to read a property
  * <pre>
  * $value=$component->propertyName;
  * </pre>
  * @param string $name the property name
  * @return mixed the property value
  * @throws \yii\base\UnknownPropertyException if the property is not defined
  * @see __set
  */
 public function __get($name)
 {
     $getter = 'get' . $name;
     if (property_exists($this->getClient(), $name)) {
         return $this->getClient()->{$name};
     } elseif (method_exists($this->getClient(), $getter)) {
         return $this->{$getter}();
     }
     return parent::__get($name);
 }
コード例 #15
0
 /**
  * @param string $name
  * @return mixed
  * @throws UnknownPropertyException
  */
 public function __get($name)
 {
     $getter = 'get' . $name;
     if (method_exists($this->getZabbixObject(), $getter)) {
         return $this->getZabbixObject()->{$getter}();
     } elseif (method_exists($this, $getter)) {
         return parent::__get($name);
     } elseif (method_exists($this, 'set' . $name)) {
         throw new InvalidCallException('Getting write-only property: ' . get_class($this) . '::' . $name);
     } else {
         throw new UnknownPropertyException('Getting unknown property: ' . get_class($this) . '::' . $name);
     }
 }
コード例 #16
0
 /**
  * Get the value of format pattern of current locale of application.
  * @param string $name
  * @return mixed
  */
 public function __get($name)
 {
     $pattern = $this->getPattern();
     if (isset($pattern[$name])) {
         return $pattern[$name];
     }
     return parent::__get($name);
 }