thunderer / Shortcode

Advanced shortcode (BBCode) parser and engine for PHP

Home Page:http://kowalczyk.cc

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Multiple options in one add handler

ideiasfrescas opened this issue · comments

Hello, we will be having a use case when we need to add similar behaviour to a couple of shortcodes, being the only difference, their name. We don't see in the documentation, so we were wondering if its possible to provide an array of possible names or pipe between them?

like so

$facade->addHandler('hello|world', function(ShortcodeInterface $s) {
    ....
});

or

$facade->addHandler(['hello','world'], function(ShortcodeInterface $s) {
    ....
});

This would considerably shrink the codebase.

Best regards

Hi @ideiasfrescas, for ShortcodeFacade this behavior is already covered by addHandlerAlias() method (see here). Can you use it instead?

Yes @thunderer

Doing so meets my use case.
Thank you.

Best regards