ElggEntity::__get PHP Method

__get() public method

If the name matches an attribute, the attribute is returned. If metadata does not exist with that name, a null is returned. This only returns an array if there are multiple values for a particular $name key.
public __get ( string $name ) : mixed
$name string Name of the attribute or metadata
return mixed
    public function __get($name)
    {
        if (array_key_exists($name, $this->attributes)) {
            if ($name === 'subtype' && $this->attributes['guid']) {
                _elgg_services()->logger->warn('Reading ->subtype on a persisted entity is unreliable.');
            }
            return $this->attributes[$name];
        }
        return $this->getMetadata($name);
    }

Usage Example

Example #1
0
 /**
  * Wrapper around \ElggEntity::__get()
  *
  * @see \ElggEntity::__get()
  *
  * @param string $name Name
  * @return mixed
  * @todo deprecate appending group to username. Was a hack used for creating
  * URLs for group content. We stopped using the hack in 1.8.
  */
 public function __get($name)
 {
     if ($name == 'username') {
         return 'group:' . $this->getGUID();
     }
     return parent::__get($name);
 }
All Usage Examples Of ElggEntity::__get