Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // existing code --------------------
- class JParameter {
- function render() {
- // return HTML with tables
- }
- // of course, there's a lot more functions here
- }
- // my magical class -----------------
- class MyParameter extends JParameter {
- function render() {
- // return HTML which doesn't suck
- }
- }
- // my code --------------------------
- $this->params->render(); // returns tables
- $this->params = (MyParameter) $this->params; // miracle occurs here?
- $this->params->render(); // returns nice html
- class MyJParameter {
- private $jparm;
- function __construct( JParameter $jparm ) {
- $this->jparm = $jparm;
- }
- function render() {
- /* your code here */
- }
- function __get( $var ) {
- if( isset( $this->$jparm->$var ) {
- return $this->$jparm->$var;
- }
- return false;
- }
- function __set( $var, $val ) {
- /* similar to __get */
- }
- function __call( $method, $arguments ) {
- if( method_exists( $this->jparm, $method ) {
- return call_user_func_array( array( $this->jparm, $method ), $arguments );
- }
- return false;
- }
- }
Add Comment
Please, Sign In to add comment