Problem/Motivation
This is a meta issue as parent for the closely related subtasks targeting partial issues.
Currently, in COOKiES, submodules provide the technical implementation for consent blocking and unblocking. Cookies Service Config Entities are created by submodules, but once they are created, there's no real connection between the submodule and the similar named Service Config Entity anymore, which is also partially described (and to be fixed) in #3323059: [2.x] Make cookies service entities created by submodules undeletable..
Second, the consentRequired checkbox in Cookies Service Entities is not used anywhere, which is tracked in: #3323044: [2.x] Use the Cookies service "Consent required" value and add tests
This leads us to the last part: blocking and unblocking services is implemented with hard coded service names, mostly in the .js files of the submodules. To connect all this correctly for more flexibility and robustness, this needs a defined connection between submodules doing the technical work and Cookies Services providing the configuration and texts.
Steps to reproduce
Proposed resolution
Introduce a Plugin System!
Drupal already has this concept: https://drupalize.me/tutorial/what-are-plugins?p=2766
Introduce sth. like interface CookiesHandlerPluginInterface (good name?) to be implemented by each submodule (one or many) and selected in the Cookies Service as handler for their blocking.
In most cases, from the current implementation. this will mean, that one submodule has one handler and the Cookies Services created by the submodule will have its handler selected.
Still a service should be able to select as many handlers as needed (in most cases that won't make sense, but there may be cases).
As all blocking / unblocking has to happen clientside, this configuration is provided as drupalSetting and if a service is accepted or declined / revoked, its related handlers methods are executed.
Remaining tasks
Find a concept to tie Cookie Service Entities to the submodules implementation for automatically and manually created Cookies Service Entities.
Comments
Comment #2
anybodyAs just discussed with @Grevil, I think we'll have to allow selecting the registered COOKiES submodule(s) in services, that should handle the consentGiven / consentDenied if the service is accepted.
Each submodule then collects the services it has to handle and provides the list to JavaScript as Javascript Settings Array. I think that's the only way it makes sense, but let's think about this once again...
Comment #3
anybodyComment #4
anybodyComment #5
anybodyComment #6
anybody@Grevil: Drupal "Plugins" is exactly, what we want!
See https://drupalize.me/tutorial/what-are-plugins?p=2766 and other sources for details. Perhaps it's also in the book.
A (bit different) example is already implemented in Fences to allow adding further tags in contrib: https://git.drupalcode.org/project/fences/-/blob/3.x/src/TagManager.php
Comment #7
anybodyComment #8
anybodyHey ho, let's go! 2.x branch was recently created. Please help to implement this or if you're not a developer, please sponsor some development hours.