sage-directives icon indicating copy to clipboard operation
sage-directives copied to clipboard

Add filters to easy overwrite or change used directives.

Open plumthedev opened this issue 4 years ago • 4 comments

Returned collection of directive can be filterable so we can easily overwrite or change directives registered to blade by this package. Now all directives all registered and we can not stop it or something.

plumthedev avatar Nov 20 '20 13:11 plumthedev

I plan on refactoring this package in the future (as time permits) – I will make that a possibility.

Log1x avatar Nov 20 '20 13:11 Log1x

Okay, thats sounds great - I can help you if you want :)

plumthedev avatar Nov 20 '20 13:11 plumthedev

I'd mainly like to do the tedious task of separating every directive into their own class and then having a service provider that has then all in an array as [Directive::class] (which will then be filterable) and calls them all.

Some of the directives need refactored as well due to the annoying amount of logic needed.

Log1x avatar Nov 20 '20 13:11 Log1x

Of course - every directive must be class with implemented __invoke magic method. We can also publish config for directives in user application - that will be good enough and can be replace with apply_filters for entire array. 

Only case where filter will be needed is before call to register it in blade eg. apply_filters('sage/blade/register_directive', true, Directive::class)

plumthedev avatar Nov 20 '20 13:11 plumthedev