Prado\TComponent::__get PHP Метод

__get() публичный Метод

Do not call this method. This is a PHP magic method that we override to allow using the following syntax to read a property: $value=$component->PropertyName; $value=$component->jsPropertyName; // return JavaScript literal and to obtain the event handler list for an event, $eventHandlerList=$component->EventName; This will also return the global event handler list when specifing an 'fx' event, $globalEventHandlerList=$component->fxEventName; When behaviors are enabled, this will return the behavior of a specific name, a property of a behavior, or an object 'on' event defined by the behavior.
public __get ( $name ) : mixed
Результат mixed the property value or the event handler list as {@link TPriorityList}
    public function __get($name)
    {
        if (method_exists($this, $getter = 'get' . $name)) {
            // getting a property
            return $this->{$getter}();
        } else {
            if (method_exists($this, $jsgetter = 'getjs' . $name)) {
                // getting a javascript property
                return (string) $this->{$jsgetter}();
            } else {
                if (strncasecmp($name, 'on', 2) === 0 && method_exists($this, $name)) {
                    // getting an event (handler list)
                    $name = strtolower($name);
                    if (!isset($this->_e[$name])) {
                        $this->_e[$name] = new TPriorityList();
                    }
                    return $this->_e[$name];
                } else {
                    if (strncasecmp($name, 'fx', 2) === 0) {
                        // getting a global event (handler list)
                        $name = strtolower($name);
                        if (!isset(self::$_ue[$name])) {
                            self::$_ue[$name] = new TPriorityList();
                        }
                        return self::$_ue[$name];
                    } else {
                        if ($this->_behaviorsenabled) {
                            // getting a behavior property/event (handler list)
                            if (isset($this->_m[$name])) {
                                return $this->_m[$name];
                            } else {
                                if ($this->_m !== null) {
                                    foreach ($this->_m->toArray() as $behavior) {
                                        if ((!$behavior instanceof IBehavior || $behavior->getEnabled()) && (property_exists($behavior, $name) || $behavior->canGetProperty($name) || $behavior->hasEvent($name))) {
                                            return $behavior->{$name};
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        throw new TInvalidOperationException('component_property_undefined', get_class($this), $name);
    }

Usage Example

Пример #1
0
 /**
  * Magic method for reading properties.
  * This method is overriden to provide read access to the foreign objects via
  * the key names declared in the RELATIONS array.
  * @param string property name
  * @return mixed property value.
  * @since 3.1.2
  */
 public function __get($name)
 {
     if ($this->hasRecordRelation($name) && !$this->canGetProperty($name)) {
         $this->fetchResultsFor($name);
         return $this->{$name};
     }
     return parent::__get($name);
 }