Extending GDPR module's consent sub-module
If you add a GDPR Consent field to anything other than a node, user, or profile, it will result in a hard fail: "The website encountered an unexpected error. Please try again later."
The error in the logs is this:
drupal: http://example.local|1527607565|php|192.168.33.1|http://example.local/donate|http://example.local/admin/structure/give|1||Exception: Could not determine user ID for entity type give_donation. Please ensure there is a resolver registered. in Drupal\gdpr_consent\ConsentUserResolver\ConsentUserResolverPluginManager->getForEntityType() (line 96 of /vagrant/web/modules/contrib/gdpr/modules/gdpr_consent/src/ConsentUserResolver/ConsentUserResolverPluginManager.php).
The resolver they talk about is not a general one, but one that the GDPR module implements itself. When it does "getDefinitions()" for "ConsentUserResolverPluginManager" this is all it returns back:
Array
(
[id] => gdpr_consent_node_resolver
[label] => GDPR Consent Node Resolver
[entityType] => node
[class] => Drupal\gdpr_consent\Plugin\Gdpr\ConsentUserResolver\NodeResolver
[provider] => gdpr_consent
)
Array
(
[id] => gdpr_consent_user_resolver
[label] => GDPR Consent User Resolver
[entityType] => user
[class] => Drupal\gdpr_consent\Plugin\Gdpr\ConsentUserResolver\UserResolver
[provider] => gdpr_consent
)
Array
(
[id] => gdpr_consent_profile_resolver
[label] => GDPR Consent Profile Resolver
[entityType] => profile
[class] => Drupal\gdpr_consent\Plugin\Gdpr\ConsentUserResolver\ProfileResolver
[provider] => gdpr_consent
)
So it seems pretty evident that for Give module's give_donation entity we need to implement a GDPR consent user resolver plugin ourselves.
Side note: determining an associated user is definitely something that should be part of Drupal's API, and not require any module to write its own code for it. It makes sense that the underlying core Entity class does not include a uid or reference to a user, but all content and profiles do so they should extend the same class or implement the same interface or something that would spare modules like GDPR this nonsense.
Comments
Post new comment