Re: Calling parent function with call_user_func_array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Nov 29, 2007 7:22 PM, Tommy Baggett <me@xxxxxxxxxx> wrote:

> Here's the exact code I tried:
>
> class Walker_NavBar extends Walker {
> ...
>
>        function walk($elements, $to_depth) {
>                $args = func_get_args();
>
> ...
>
>                // call base class implementation
>                return call_user_func_array(array(parent,'walk'),$args);
>        }
> ...


wow; i was just looking at the wordpress source;  not the prettiest code ive
ever seen..
anyway; in what context do you intend to use the subclass?  why dont you
just create a
proxy instead?
eg. (php4)

class WalkerProxy {
    var $walkerInstance = null;

    /**
     * constructor
     *   accept an existing walker instance or create one from scratch
     */
    function WalkerProxy($existingWalker=null) {
        if(!is_null($existingWalker) && is_a($existingWalker, 'Walker') {
            $this->walkerInstance = $existingWalker;
        } else {
            $this->walkerInstance = new Walker();
        }
    }

    /**
     * walk
     *    do custom WalkerProxy stuff then invoke the underlying Walker's
walk() method
     */
    function walk($elements, $to_depth) {
         //// do something custom here
        return $this->walkerInstance($elements, $to_depth);
    }

   /// .....
}

-nathan

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux