ignore prefixed attributes
This commit is contained in:
parent
75a77b3f5c
commit
1fe8c26b1d
1 changed files with 23 additions and 0 deletions
|
@ -462,6 +462,24 @@ class Base_Object {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic function, to transform the object to string.
|
||||
*
|
||||
* @return string The object id.
|
||||
*/
|
||||
public function __toString() {
|
||||
return $this->to_string();
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to transform the object to string.
|
||||
*
|
||||
* @return string The object id.
|
||||
*/
|
||||
public function to_string() {
|
||||
return $this->get_id();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic getter.
|
||||
*
|
||||
|
@ -575,6 +593,11 @@ class Base_Object {
|
|||
$vars = get_object_vars( $this );
|
||||
|
||||
foreach ( $vars as $key => $value ) {
|
||||
// ignotre all _prefixed keys.
|
||||
if ( '_' === substr( $key, 0, 1 ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// if value is empty, try to get it from a getter.
|
||||
if ( ! isset( $value ) ) {
|
||||
$value = call_user_func( array( $this, 'get_' . $key ) );
|
||||
|
|
Loading…
Reference in a new issue