__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
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);
 }
Example #2
0
 /**
  * Need to catch attempts to test user for admin.  Remove for 1.9
  *
  * @param string $name Name
  *
  * @return bool
  */
 public function __get($name)
 {
     if ($name == 'admin' || $name == 'siteadmin') {
         elgg_deprecated_notice('The admin/siteadmin metadata are not longer used.  Use ElggUser->isAdmin().', 1.7);
         return $this->isAdmin();
     }
     return parent::__get($name);
 }