Re[2]: [PEAR-DEV] [PEPr] Proposal for PEAR::PEAR_Delegator
| From: | Sven Fuchs | Date: | Fri, 04 Mar 2005 16:16:06 +0000 |
| Subject: | Re[2]: [PEAR-DEV] [PEPr] Proposal for PEAR::PEAR_Delegator | ||
| References: | 1 2 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-36532@lists.php.net to get a copy of this message | ||
> Shall I assume everyone is satisfied with the proposal as it stands?
> Checkout http://pear.php.net/pepr/pepr-proposal-show.php?id=210
Just done this ... Great! :)
Hmm, you've already started voting, so I hope I'm not too late with
the following:
* Thus, delegated methods must be defined as follows:
* <code>
* accesslevel function functionName($owner, ...);
* </code>
* Note, however, that the user of the method need only consider those
* parameters that follow the first parameter.
So, it's impossible to delegate to already existing classes without
modifying them, since __call() prepends the Delegator to the arguments
of the called method?
I tried to delegate the Dataspace class from Wact,
http://wact.sourceforge.net/xref/framework/util/dataspace.inc.php.source.html
class MyTestDelegator extends PEAR_Delegator {
function __construct() {
$this->addDelegate(new Dataspace());
}
}
$test = new MyTestDelegator();
$test->set('foo', 'bar');
... won't work, since Dataspace::set($name, $value) gets called with
the arguments set($delegator, $name, $value). (Or possibly I've just
missed the intended way to get around this?)
That would mean, that we could only delegate to classes, that are
explicitly ment to be used as delegates.
A simple way around that could be to append (not prepend) the
Delegator to the arguments:
in PEAR_Delegator::__call()
$args = array_merge($args, array($delegate));
instead of
$args = array_merge(array($delegate), $args);
I'd really apreciate to be able to delegate existing classes without
having to modify them ...
Regards,
Sven