laravel-menu
laravel-menu copied to clipboard
Override some methods, best way?
I need to override the method
Builder.php -> mergeStatic
switching in $attrs and $old like
$attrs['class'] = self::formatGroupClass($old, $attrs);
because I need to "add" class values after the blade template inserted one, but I can't realise how to do it. I create a new MyBuilder class that extends the Builder.php one, but how can I say that the app to use myBuilder instead of the old one.
How can i do this?
Hi @ItsLhoudini sorry for the delay.
I've reviewed the code, but I don't think I can come up with a clever way to work around this. One option would be to:
- Extend
MyBuilder
as you have done. - Create your own
Blade::extend(...)
similar to the one in lm-attrs.php but use a different matcher pattern. Likemy-endattrs
and use MyBuilder in the replacement call. - Copy and edit the bootstrap-navbar-items.blade.php to use your new blade extensions like
@my-endattrs
But, this is not very elegant or user friendly.
I think I will need to update the blade extension to allow extending the MyBuilder class, so that you would only need to replace the single function.
Do you still need this?