How inefficient is it, exactly? Is there a measurable performance impact?
My recommendation under ideal circumstances would be to use closures (needs PHP 5.3) to wrap a parameter to your real callback; on older versions you could use create_function which is ugly, but probably not much worse for performance.
-- brion On Dec 21, 2011 8:48 AM, "Daniel Barrett" danb@vistaprint.com 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
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l