thunderer / Shortcode

Advanced shortcode (BBCode) parser and engine for PHP
http://kowalczyk.cc
MIT License
378 stars 29 forks source link

Multiple options in one add handler #92

Closed ideiasfrescas closed 3 years ago

ideiasfrescas commented 3 years ago

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

thunderer commented 3 years ago

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

ideiasfrescas commented 3 years ago

Yes @thunderer

Doing so meets my use case. Thank you.

Best regards