laravel-menu icon indicating copy to clipboard operation
laravel-menu copied to clipboard

Override some methods, best way?

Open wondergitluda opened this issue 8 years ago • 1 comments

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?

wondergitluda avatar Jul 27 '16 09:07 wondergitluda

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:

  1. Extend MyBuilder as you have done.
  2. Create your own Blade::extend(...) similar to the one in lm-attrs.php but use a different matcher pattern. Like my-endattrs and use MyBuilder in the replacement call.
  3. 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?

dustingraham avatar Sep 27 '17 04:09 dustingraham