I think it will throw an exception every time, since you're going to
call a non-existent function for any action (you call methody() on
ActionX, which doesn't exist; you call methodx() on ActionY, which
doesn't exist; and you call methodx() and methody() on all other action
classes, which also won't exist).
Also, note that action classes in StatusNet are usually named XAction,
not ActionX.
If I needed to run this, I'd do something like:
// get the 'action' parameter
$actionName = $action->trimmed('action');
switch ($actionName) {
case 'x':
$action->methodx();
break;
case 'y':
$action->methody();
break;
default:
// do nothing
break;
}
return true;
You could also check the class of the $action object; that should work,
too.
-Evan
On Sun, 2010-11-07 at 09:26 +0800, 橡树 wrote:
> Hi, everyone
>
> Let's us suppose we have a event handler as following.
>
> /****************************************/
> //plugina.php
> ......
> class PluginA extends Plugin
> {
> function onStartPrimaryNav($action)
> {
> return true;
> }
> }
> ......
> /****************************************/
>
> When we browser http://localhost/statusnet/index.php/actionx, the
> $action is an ActionX object. The ActionX object has a unique method
> methodx().
>
> When we browser http://localhost/statusnet/index.php/actiony, the
> $action is an ActionY object. The ActionY object has a unique method
> methody().
>
> If we write the event handler as following, what will happen?
>
> /****************************************/
> //plugina.php
> ......
> class PluginA extends Plugin
> {
> function onStartPrimaryNav($action)
> {
> $action->methodx();
> $action->methody();
> return true;
> }
> }
> ......
> /****************************************/
>
> Is my suppose possible? Is my suppose reasonable?
>
> I'm a newbie in StatusNet, so I hope you will not mind my strange
> questions.
>
> Regards,
> Blue
>
>
> _______________________________________________
> StatusNet-dev mailing list
> [email protected]
> http://lists.status.net/mailman/listinfo/statusnet-dev
--
Evan Prodromou, CEO, StatusNet Inc.
1124 rue Marie-Anne Est #32, Montreal, QC, Canada H2J 2B7
E: [email protected] T: 438-380-4801 x101 W: http://evan.status.net/
_______________________________________________
StatusNet-dev mailing list
[email protected]
http://lists.status.net/mailman/listinfo/statusnet-dev