This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

nsrosenqvist
nsrosenqvist

Hi, I've been having trouble with a plugin I'm developing. It's super simple and just provides a twig filter, however I want it to be configurable but I'd also like to be able to use the plugin without having to include a component on every layout it's used, like I can now that I register the filter in the Plugin.php file. But I need a component to allow configuration and then I run into a lot of implementation issues.

  1. I can't register the filter in the component (which is needed for configuration - and I don't want it backend based since the plugin features is only relevant for theme authors). If I would do it I would have to include it everywhere I want the filter to be used.
  2. If I register the filter in Plugin.php I need to have all component methods to be static since twig filters have to be static. That don't work since the component config is passed to an instance of it.
  3. I tried using a ServiceProvider to register a facade to use for the instance which would work if not something in core checks that the object is of the component class (and it's not, it checks this on the facade).

Any ideas on how to implement this in a way that works? I think that the facade way should work if it just passes the validation.

Thanks, all ideas are appreciated!

1-1 of 1

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.