- Issue created by @Anybody
- 🇩🇪Germany Anybody Porta Westfalica
PS: You'll need to implement the same here (posthog module): 📌 Implement typical configuration & exclusions settings Active
And we should write some documentation, as it seems to be super undocumented... (or isn't possible through Conditions API)
- 🇩🇪Germany Anybody Porta Westfalica
The context module for example also implements conditions very well, see https://git.drupalcode.org/project/context/-/blob/8.x-4.x/src/Entity/Con...
Maybe you want to install the module and try it out to get an idea and implement it likewise.
You should also be able to see relevant parts of the config schema there.Unsure which other modules use it.
You can find the core implementation here: https://git.drupalcode.org/project/drupal/-/tree/11.x/core/lib/Drupal/Co...
- 🇩🇪Germany Anybody Porta Westfalica
Okay here you go: Various contrib sources: https://git.drupalcode.org/search?group_id=2&scope=blobs&search=Conditio...
Still I think context is one of the most reliable as widely used and mature!Asset injector is another one, but both use entities. I'd like to find an example with a settings page...
I finally also found https://git.drupalcode.org/project/core_extend/-/blob/8.x-1.x/src/Form/C... in contrib, which would be super helpful and decided to create a core issue: ✨ Provide a ConditionsFormTrait or form element for conditions Active
But we shouldn't wait for that! - 🇩🇪Germany Anybody Porta Westfalica
Here's the best implementation of Condition Plugins I've found for a settings page: https://git.drupalcode.org/project/advanced_mautic_integration/-/blob/1....
- Merge request !2Issue #3482684: Use Drupal Conditions Plugin API to include / exclude by certain conditions → (Merged) created by Anybody
- 🇩🇪Germany Anybody Porta Westfalica
Yay, it works!! :)
Now the condition validation... - 🇩🇪Germany Anybody Porta Westfalica
Credits to https://www.drupal.org/project/advanced_mautic_integration → and https://www.drupal.org/project/lazyloader → - their implementation helped me a lot to understand how condition plugins work. A lot of there code was used here, great work!!
- 🇩🇪Germany Anybody Porta Westfalica
Please note that currently the condition plugins are always affected by ✨ Create an admin route condition plugin or add generic "Current theme" options for admin and default theme Active which leads to wrong results, as the "Current theme" condition is always evaluated with the preselected value!
Automatically closed - issue fixed for 2 weeks with no activity.