Islandora / documentation

Contains islandora's documentation and main issue queue.
MIT License
104 stars 71 forks source link

Custom condition plugins break Google Tag Manager module #1887

Open seth-shaw-unlv opened 3 years ago

seth-shaw-unlv commented 3 years ago

The Google Tag Manager (GTM) module (google_tags) uses conditions. When our condition forms include required fields it prevents the module from saving the GTM container configuration.

I can think of two solutions: either we remove them ala our block placement form alter OR we remove the required attributes from our condition plugin forms (so we don't have to do this for every module that uses conditions) at the expense of condition usability.

Thoughts, @Islandora/8-x-committers?

seth-shaw-unlv commented 3 years ago

Learn something new every day. You can filter plugins at runtime for a given consumer.

This means I can explicitly filter out certain condition plugins based on the consumer. For GTM I was able to add the following to our custom islandora_local.module file:

/**
 * Filter condition plugins out of the google tag form.
 */
function islandora_local_plugin_filter_condition__google_tag_alter(&$definitions, array $extra) {
  unset($definitions['content_entity_type']);
  unset($definitions['file_uses_filesystem']);
  unset($definitions['media_has_mimetype']);
  unset($definitions['media_has_term']);
  unset($definitions['media_is_islandora_media']);
  unset($definitions['media_uses_filesystem']);
  unset($definitions['node_had_namespace']);
  unset($definitions['node_has_parent']);
  unset($definitions['node_has_term']);
  unset($definitions['node_is_islandora_object']);
  unset($definitions['node_referenced_by_node']);
  unset($definitions['parent_node_has_term']);
}

This removed the conditions for the form. (Trying to do this in the form alter as we do for blocks caused it to crash when saving the form.) But I don't think that we want to do this for every possible consumer we come across...

So perhaps (untested working theory here) we can implement hook_plugin_filter_TYPE_alter in the islandora module and unset them except when the consumer is the Context module?