allow setter/getter for own attributes in plugins

git-svn-id: file:///svn/phpbb/trunk@9255 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen 2009-01-13 17:07:55 +00:00
parent 7e60f634b4
commit fde2671cfa

View file

@ -543,24 +543,44 @@ abstract class phpbb_plugin_support
* @access public * @access public
*/ */
public function __get($name) public function __get($name)
{
if (isset($this->plugin_attributes[$name]))
{ {
return $this->plugin_attributes[$name]->$name; return $this->plugin_attributes[$name]->$name;
} }
return $this->$name;
}
public function __set($name, $value) public function __set($name, $value)
{
if (isset($this->plugin_attributes[$name]))
{ {
return $this->plugin_attributes[$name]->$name = $value; return $this->plugin_attributes[$name]->$name = $value;
} }
return $this->$name = $value;
}
public function __isset($name) public function __isset($name)
{
if (isset($this->plugin_attributes[$name]))
{ {
return isset($this->plugin_attributes[$name]->$name); return isset($this->plugin_attributes[$name]->$name);
} }
return isset($this->$name);
}
public function __unset($name) public function __unset($name)
{
if (isset($this->plugin_attributes[$name]))
{ {
unset($this->plugin_attributes[$name]->$name); unset($this->plugin_attributes[$name]->$name);
} }
unset($this->$name);
}
/**#@-*/ /**#@-*/
/** /**
@ -568,11 +588,16 @@ abstract class phpbb_plugin_support
* @access public * @access public
*/ */
public function __call($name, $arguments) public function __call($name, $arguments)
{
if (isset($this->plugin_methods[$name]) && !is_array($this->plugin_methods[$name]))
{ {
array_unshift($arguments, $this); array_unshift($arguments, $this);
return call_user_func_array(array($this->plugin_methods[$name], $name), $arguments); return call_user_func_array(array($this->plugin_methods[$name], $name), $arguments);
} }
trigger_error('Call to undefined method ' . $name . '() in ' . get_class($this) . '.', E_USER_ERROR);
}
/** /**
* Checks if a specific method is overridden by a hook * Checks if a specific method is overridden by a hook
* Called within methods to check if they are overridden. * Called within methods to check if they are overridden.