From 7c13c8e96367095d8b1df50f7506bdd7d902a281 Mon Sep 17 00:00:00 2001 From: Mark Hanna Date: Tue, 23 Jan 2024 13:58:21 -0600 Subject: [PATCH] moving Rules integration to a submodule --- civicrm_entity.module | 28 --------------- .../civicrm_entity_rules.info.yml | 8 +++++ .../civicrm_entity_rules.module | 34 +++++++++++++++++++ .../src}/Plugin/Condition/ContactInGroup.php | 4 +-- .../src}/Plugin/Condition/DrupalUserExist.php | 2 +- .../Condition/DrupalUserExistsContactId.php | 2 +- .../Plugin/RulesAction/LoadLinkedUser.php | 2 +- .../src}/Plugin/RulesAction/UserCreate.php | 2 +- .../TypedDataFilter/FirstDotLastFilter.php | 2 +- .../TypedDataFilter/FirstLastFilter.php | 2 +- .../TypedDataFilter/InitialDotLastFilter.php | 2 +- .../TypedData/Options/CivicrmGroupOptions.php | 0 12 files changed, 51 insertions(+), 37 deletions(-) create mode 100644 modules/civicrm_entity_rules/civicrm_entity_rules.info.yml create mode 100644 modules/civicrm_entity_rules/civicrm_entity_rules.module rename {src => modules/civicrm_entity_rules/src}/Plugin/Condition/ContactInGroup.php (95%) rename {src => modules/civicrm_entity_rules/src}/Plugin/Condition/DrupalUserExist.php (98%) rename {src => modules/civicrm_entity_rules/src}/Plugin/Condition/DrupalUserExistsContactId.php (98%) rename {src => modules/civicrm_entity_rules/src}/Plugin/RulesAction/LoadLinkedUser.php (98%) rename {src => modules/civicrm_entity_rules/src}/Plugin/RulesAction/UserCreate.php (99%) rename {src => modules/civicrm_entity_rules/src}/Plugin/TypedDataFilter/FirstDotLastFilter.php (95%) rename {src => modules/civicrm_entity_rules/src}/Plugin/TypedDataFilter/FirstLastFilter.php (95%) rename {src => modules/civicrm_entity_rules/src}/Plugin/TypedDataFilter/InitialDotLastFilter.php (95%) rename {src => modules/civicrm_entity_rules/src}/TypedData/Options/CivicrmGroupOptions.php (100%) diff --git a/civicrm_entity.module b/civicrm_entity.module index eb77d361..664bc14a 100644 --- a/civicrm_entity.module +++ b/civicrm_entity.module @@ -706,34 +706,6 @@ function civicrm_entity_rebuild() { } } -/** - * Implements hook_rules_action_info_alter(). - */ -function civicrm_entity_rules_action_info_alter(&$rules_actions) { - $definitions = \Drupal::service('plugin.manager.typed_data_filter')->getDefinitions(); - $filters = ""; - foreach ($definitions as $key) { - if ($key['provider'] == 'civicrm_entity') { - $filters .= ($filters == '' ? '' : ', ') . $key['id']; - } - } - if (array_key_exists('format', $rules_actions['civicrm_entity_user_create']['context_definitions'])) { - // Drupal 9 use 'context_definitions' instead of 'context'. - $rules_actions['civicrm_entity_user_create']['context_definitions']['format']->setDescription(t('Format of the username. Use Twig style tokens for using the available data.
Civicrm Entity filter available : @filters.', - [ - '@url' => 'https://www.drupal.org/docs/8/modules/typed-data-api-enhancements/typeddata-tokens', - '@filters' => $filters, - ])); - } - else { - $rules_actions['civicrm_entity_user_create']['context']['format']->setDescription(t('Format of the username. Use Twig style tokens for using the available data.
Civicrm Entity filter available : @filters.', - [ - '@url' => 'https://www.drupal.org/docs/8/modules/typed-data-api-enhancements/typeddata-tokens', - '@filters' => $filters, - ])); - } -} - /** * Implements hook_search_api_datasource_info_alter(). */ diff --git a/modules/civicrm_entity_rules/civicrm_entity_rules.info.yml b/modules/civicrm_entity_rules/civicrm_entity_rules.info.yml new file mode 100644 index 00000000..4b70f401 --- /dev/null +++ b/modules/civicrm_entity_rules/civicrm_entity_rules.info.yml @@ -0,0 +1,8 @@ +name: CiviCRM Entity Rules +type: module +description: 'Rules plugins for CiviCRM Entity types' +package: CiviCRM +core_version_requirement: ^10 +dependencies: + - civicrm_entity:civicrm_entity + - rules:rules diff --git a/modules/civicrm_entity_rules/civicrm_entity_rules.module b/modules/civicrm_entity_rules/civicrm_entity_rules.module new file mode 100644 index 00000000..d51277ab --- /dev/null +++ b/modules/civicrm_entity_rules/civicrm_entity_rules.module @@ -0,0 +1,34 @@ +getDefinitions(); + $filters = ""; + foreach ($definitions as $key) { + if ($key['provider'] == 'civicrm_entity_rules') { + $filters .= ($filters == '' ? '' : ', ') . $key['id']; + } + } + if (array_key_exists('format', $rules_actions['civicrm_entity_user_create']['context_definitions'])) { + // Drupal 9 use 'context_definitions' instead of 'context'. + $rules_actions['civicrm_entity_user_create']['context_definitions']['format']->setDescription(t('Format of the username. Use Twig style tokens for using the available data.
Civicrm Entity filter available : @filters.', + [ + '@url' => 'https://www.drupal.org/docs/8/modules/typed-data-api-enhancements/typeddata-tokens', + '@filters' => $filters, + ])); + } + else { + $rules_actions['civicrm_entity_user_create']['context']['format']->setDescription(t('Format of the username. Use Twig style tokens for using the available data.
Civicrm Entity filter available : @filters.', + [ + '@url' => 'https://www.drupal.org/docs/8/modules/typed-data-api-enhancements/typeddata-tokens', + '@filters' => $filters, + ])); + } +} \ No newline at end of file diff --git a/src/Plugin/Condition/ContactInGroup.php b/modules/civicrm_entity_rules/src/Plugin/Condition/ContactInGroup.php similarity index 95% rename from src/Plugin/Condition/ContactInGroup.php rename to modules/civicrm_entity_rules/src/Plugin/Condition/ContactInGroup.php index 8a443b68..c52bc716 100644 --- a/src/Plugin/Condition/ContactInGroup.php +++ b/modules/civicrm_entity_rules/src/Plugin/Condition/ContactInGroup.php @@ -1,6 +1,6 @@