On 21/12/11 17:47, Daniel Barrett wrote:
Happy Melon suggests:
foreach( array( 'foo', 'bar', 'baz', quok' ) as $var ){ $parser->setHook( $var, "WrapperClass::myCallback_$var" ); } ...
Thanks for the suggestion. I am already doing something similar (see my original note about "dynamically creating 20 callbacks" today), but it's inefficient when only 1 tag is actually used on the page, which is 99% of the time. (And actually my number "20" is really more like "75".) I'm hoping for a technique that creates only the callback I need on that page. Hence, the desire to know the name of the tag that called me.
I was thinking of suggesting a core code change that adds the tag name as one of the args of the callback function (e.g., $args['_MW_TAG_NAME_']), but that might break any tag extensions that expect a certain count($args).
I'm still hoping that $parser->getMyTagNameThatCalledMe() function exists somewhere.....?
DanB
No. $name is not passed to the hook call. The only -and fragile- way to retrieve it would be something like:
$debug = wfDebugBacktrace(1); if (count($debug)) { $name = $frame->expand( $debug[1]['args'][0] ); } else { $name = 'no name'; }