Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions core/includes/class-rcp-component.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ class Component extends Base_Object {
*/
private $interfaces = array();

/**
* Array of dynamicKeys
*
* @since 3.4
* @var array
*/
private $dynamicKeys = array();

/**
* Returns an interface object
*
Expand All @@ -35,7 +43,7 @@ class Component extends Base_Object {
*/
public function get_interface( $key ) {
return isset( $this->interfaces[ $key ] ) ? $this->interfaces[ $key ] : false;
}
}

/**
* Set up interfaces
Expand All @@ -59,11 +67,18 @@ protected function set_vars( $args = array() ) {
if ( in_array( $key, $keys, true ) && class_exists( $value ) ) {
$this->interfaces[ $key ] = new $value;
} else {
$this->{$key} = $value;
$this->dynamicKeys[$key] = $value;
}

}

}

public function __get(string $name) {
if(property_exists($this, $name))
return $this->$name;
else
return $this->dynamicKeys[$name];
}

}