From e3b67f35fa915dcab015af0c1ee96f61eed91a27 Mon Sep 17 00:00:00 2001 From: Mark Hanna Date: Mon, 29 Apr 2024 15:05:26 -0600 Subject: [PATCH 01/15] supportedentities update AllCoreTables function (#479) --- src/SupportedEntities.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SupportedEntities.php b/src/SupportedEntities.php index d089b77c..727fe7ba 100644 --- a/src/SupportedEntities.php +++ b/src/SupportedEntities.php @@ -882,7 +882,7 @@ public static function getEntityNameFromCamel($entity) { public static function getEntityTypeDaoClass($entity_type_id) { \Drupal::service('civicrm_entity.api')->civicrmInitialize(); - $tables = \CRM_Core_DAO_AllCoreTables::getCoreTables(); + $tables = \CRM_Core_DAO_AllCoreTables::tables(); return $tables[$entity_type_id] ?? NULL; } From cbbc74ea0a495d9555fcbaf855294eca87fab934 Mon Sep 17 00:00:00 2001 From: puresyntax71 <34715246+puresyntax71@users.noreply.github.com> Date: Tue, 30 Apr 2024 05:05:49 +0800 Subject: [PATCH 02/15] Add pcp. (#477) --- src/SupportedEntities.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/SupportedEntities.php b/src/SupportedEntities.php index 727fe7ba..ad968515 100644 --- a/src/SupportedEntities.php +++ b/src/SupportedEntities.php @@ -714,6 +714,18 @@ public static function getInfo() { ], ]; + $civicrm_entity_info['civicrm_pcp'] = [ + 'civicrm entity label' => t('Personal Campaign Page'), + 'civicrm entity name' => 'pcp', + 'label property' => 'title', + 'permissions' => [ + 'view' => [], + 'update' => [], + 'create' => [], + 'delete' => [], + ], + ]; + static::alterEntityInfo($civicrm_entity_info); // Check if API finds each entity type. // Necessary for tests/civi upgrade after, From 8876e95bf0fbc6d5cd7c654233cd45822ecc705b Mon Sep 17 00:00:00 2001 From: puresyntax71 <34715246+puresyntax71@users.noreply.github.com> Date: Tue, 30 Apr 2024 05:24:00 +0800 Subject: [PATCH 03/15] Adds Checksum validation solution for Drupal Views (#478) * Adds Checksum validation solution for Drupal Views * Fix indent * Shifts to use dependency injection * Shift logger to use LoggerChannelTrait * Request vis depency injection * Fix typo * WIP Attempting to fix dependency injection abject failure awaits * Coding standards. --------- Co-authored-by: Luke Stewart --- civicrm_entity.services.yml | 7 ++ src/Access/ContactChecksumCheckAccess.php | 87 +++++++++++++++ src/Plugin/views/access/ContactChecksum.php | 111 ++++++++++++++++++++ 3 files changed, 205 insertions(+) create mode 100644 src/Access/ContactChecksumCheckAccess.php create mode 100644 src/Plugin/views/access/ContactChecksum.php diff --git a/civicrm_entity.services.yml b/civicrm_entity.services.yml index db96d08d..1aab2565 100644 --- a/civicrm_entity.services.yml +++ b/civicrm_entity.services.yml @@ -25,3 +25,10 @@ services: arguments: ['@civicrm_entity.module_installer.inner', '%app.root%', '@module_handler', '@kernel', '@database', '@update.update_hook_registry'] tags: - { name: service_collector, tag: 'module_install.uninstall_validator', call: addUninstallValidator } + + civicrm_entity.contact_checksum_access_checker: + class: Drupal\civicrm_entity\Access\ContactChecksumCheckAccess + autowire: true + arguments: ['@request_stack', '@civicrm_entity.api'] + tags: + - {name: access_check, applies_to: _civicrm_entity_checksum_access_check } diff --git a/src/Access/ContactChecksumCheckAccess.php b/src/Access/ContactChecksumCheckAccess.php new file mode 100644 index 00000000..d1ac9025 --- /dev/null +++ b/src/Access/ContactChecksumCheckAccess.php @@ -0,0 +1,87 @@ +requestStack = $request_stack; + $this->civicrmApi = $civicrm_api; + } + + /** + * A custom access check. + * + * @param \Drupal\Core\Session\AccountInterface $account + * Run access checks for this account. + * @param \Symfony\Component\Routing\Route $route + * The route for which an access check is being done. + * + * @return \Drupal\Core\Access\AccessResultInterface + * The access result. + */ + public function access(AccountInterface $account, Route $route) { + $options = unserialize($route->getRequirement('var_options')); + + $access_by_role = !empty(array_intersect(array_filter($options['role']), $account->getRoles())); + if ($access_by_role) { + $this->getlogger('ContactChecksumCheckAccess')->info('Access by role'); + return AccessResult::allowed(); + } + $request = $this->requestStack->getCurrentRequest(); + + $cid1 = filter_var($request->query->get('cid1'), FILTER_VALIDATE_INT, ['options' => ['min_range' => 1]]); + $checksum = $request->query->get('cs'); + + if (empty($cid1) || empty($checksum)) { + $this->getlogger('ContactChecksumCheckAccess')->info('No cid1 or cs param'); + return AccessResult::forbidden(); + } + + // This forces a call to Civicrm initialize. + $this->civicrmApi->getFields('Contact'); + + $results = Contact::validateChecksum(FALSE) + ->setContactId($cid1) + ->setChecksum($checksum) + ->execute(); + return empty($results[0]['valid']) ? AccessResult::forbidden() : AccessResult::allowed(); + } + +} diff --git a/src/Plugin/views/access/ContactChecksum.php b/src/Plugin/views/access/ContactChecksum.php new file mode 100644 index 00000000..c07462a6 --- /dev/null +++ b/src/Plugin/views/access/ContactChecksum.php @@ -0,0 +1,111 @@ +requestStack = $container->get('request_stack'); + $instance->civicrmApi = $container->get('civicrm_entity.api'); + + return $instance; + } + + /** + * {@inheritdoc} + */ + public function access(AccountInterface $account) { + // Check if logged in and has access. + $logged_in_access = parent::access($account); + + if ($logged_in_access) { + return TRUE; + } + $request = $this->requestStack->getCurrentRequest(); + $cid1 = filter_var($request->query->get('cid1'), FILTER_VALIDATE_INT, ['options' => ['min_range' => 1]]); + $checksum = $request->query->get('cs'); + + // Force CiviCRM to be intialized - ideally we'd use the api + // wrapper however it's api3 and we need api4. + // This forces a call to Civicrm initialize. + $this->civicrmApi->getFields('Contact'); + + $results = Contact::validateChecksum(FALSE) + ->setContactId($cid1) + ->setChecksum($checksum) + ->execute(); + return !empty($results[0]['valid']) ?? FALSE; + } + + /** + * {@inheritdoc} + */ + public function alterRouteDefinition(Route $route) { + $route->setRequirement('_civicrm_entity_checksum_access_check', 'TRUE'); + $route->setRequirement('var_options', serialize($this->options)); + } + + /** + * {@inheritdoc} + */ + public function getCacheMaxAge() { + // Ideally we would expire based on the age of the checksum + // however this might not work for anon users. So no caching. + // https://www.drupal.org/docs/drupal-apis/cache-api/cache-max-age + return 0; + } + + /** + * {@inheritdoc} + */ + public function getCacheContexts() { + $contexts = parent::getCacheContexts(); + $contexts[] = 'url.query_args:checksum'; + $contexts[] = 'url.query_args:cid'; + return $contexts; + } + + /** + * {@inheritdoc} + */ + public function getCacheTags() { + return []; + } + +} From 5412b32503529069355bbaccac3af9246dad2fea Mon Sep 17 00:00:00 2001 From: Mark Hanna Date: Tue, 30 Apr 2024 12:44:26 -0600 Subject: [PATCH 04/15] deprecation fixes for D11 (#480) --- civicrm_entity.info.yml | 2 +- src/CiviEntityStorage.php | 24 ++++++++++++++++++- .../views/relationship/CiviCrmContactUser.php | 14 +++++++++-- 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/civicrm_entity.info.yml b/civicrm_entity.info.yml index 35134dc8..6a57a80a 100644 --- a/civicrm_entity.info.yml +++ b/civicrm_entity.info.yml @@ -2,7 +2,7 @@ name: CiviCRM Entity type: module description: 'Expose CiviCRM entities as Drupal entities.' package: CiviCRM -core_version_requirement: ^10 +core_version_requirement: ^10 || ^11 dependencies: - civicrm - drupal:datetime diff --git a/src/CiviEntityStorage.php b/src/CiviEntityStorage.php index d6421270..e76bc252 100644 --- a/src/CiviEntityStorage.php +++ b/src/CiviEntityStorage.php @@ -13,9 +13,11 @@ use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\Language\LanguageInterface; +use Drupal\Core\Utility\Error; use Drupal\datetime\Plugin\Field\FieldType\DateTimeItem; use Drupal\datetime\Plugin\Field\FieldType\DateTimeItemInterface; use Drupal\field\FieldStorageConfigInterface; +use Psr\Log\LoggerInterface; /** * Defines entity class for external CiviCRM entities. @@ -43,6 +45,13 @@ class CiviEntityStorage extends SqlContentEntityStorage { */ protected $entityFieldManager; + /** + * The Logger. + * + * @var \Psr\Log\LoggerInterface + */ + protected $logger; + /** * Gets the CiviCRM API. * @@ -69,6 +78,19 @@ private function getConfigFactory() { return $this->configFactory; } + /** + * Gets the config factory. + * + * @return \Psr\Log\LoggerInterface + * The logger channel. + */ + private function getLogger() { + if (!$this->logger) { + $this->logger = \Drupal::logger('civicrm_entity'); + } + return $this->logger; + } + /** * Initializes table name variables. */ @@ -203,7 +225,7 @@ protected function doLoadMultiple(array $ids = NULL) { } } catch (\Exception $e) { - watchdog_exception('civicrm_entity', $e); + Error::logException($this->getLogger(), $e); } } diff --git a/src/Plugin/views/relationship/CiviCrmContactUser.php b/src/Plugin/views/relationship/CiviCrmContactUser.php index 25d1e4c8..405589f8 100644 --- a/src/Plugin/views/relationship/CiviCrmContactUser.php +++ b/src/Plugin/views/relationship/CiviCrmContactUser.php @@ -3,7 +3,9 @@ namespace Drupal\civicrm_entity\Plugin\views\relationship; use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\Utility\Error; use Symfony\Component\DependencyInjection\ContainerInterface; +use Psr\Log\LoggerInterface; /** * Relationship for referencing civicrm_contact and user. @@ -21,12 +23,20 @@ class CiviCrmContactUser extends CiviCrmBridgeRelationshipBase { */ protected $civicrmApi; + /** + * The Logger. + * + * @var \Psr\Log\LoggerInterface + */ + protected $logger; + /** * {@inheritdoc} */ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { $instance = parent::create($container, $configuration, $plugin_id, $plugin_definition); $instance->civicrmApi = $container->get('civicrm_entity.api'); + $instance->logger = $container->get('logger.factory')->get('civicrm_entity'); return $instance; } @@ -60,7 +70,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { } } catch (\Exception $e) { - watchdog_exception('civicrm_entity', $e); + Error::logException($this->logger, $e); } $form['domain_id'] = [ @@ -100,7 +110,7 @@ protected function getExtras() { } } catch (\Exception $e) { - watchdog_exception('civicrm_entity', $e); + Error::logException($this->logger, $e); } } } From 6c3d00d0ec2987d956d69aa54d328660e52ed1b4 Mon Sep 17 00:00:00 2001 From: Mark Hanna Date: Fri, 17 May 2024 12:22:48 -0600 Subject: [PATCH 05/15] update composer.json for Drupal 11 (#482) --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 991eb42f..bb28e01c 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,7 @@ "homepage": "http://drupal.org/project/civicrm_entity", "license": "GPL-2.0+", "require": { - "drupal/core": "^10", + "drupal/core": "^10 || ^11", "civicrm/civicrm-drupal-8": "*" }, "require-dev": { From 37fabc16f01497f03e54b239e926a565436249ab Mon Sep 17 00:00:00 2001 From: Mark Hanna Date: Mon, 20 May 2024 16:36:14 -0600 Subject: [PATCH 06/15] adding logger parameter to ModulerInstaller service (#483) * adding logger parameter to ModulerInstaller service * services yaml fix * require Drupal 10.1 * require Drupal 10.1 --- civicrm_entity.info.yml | 2 +- civicrm_entity.services.yml | 2 +- composer.json | 2 +- src/ModuleInstaller.php | 6 ++++-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/civicrm_entity.info.yml b/civicrm_entity.info.yml index 6a57a80a..19a47c18 100644 --- a/civicrm_entity.info.yml +++ b/civicrm_entity.info.yml @@ -2,7 +2,7 @@ name: CiviCRM Entity type: module description: 'Expose CiviCRM entities as Drupal entities.' package: CiviCRM -core_version_requirement: ^10 || ^11 +core_version_requirement: ^10.1 || ^11 dependencies: - civicrm - drupal:datetime diff --git a/civicrm_entity.services.yml b/civicrm_entity.services.yml index 1aab2565..3edddd81 100644 --- a/civicrm_entity.services.yml +++ b/civicrm_entity.services.yml @@ -22,7 +22,7 @@ services: class: Drupal\civicrm_entity\ModuleInstaller decorates: module_installer public: true - arguments: ['@civicrm_entity.module_installer.inner', '%app.root%', '@module_handler', '@kernel', '@database', '@update.update_hook_registry'] + arguments: ['@civicrm_entity.module_installer.inner', '%app.root%', '@module_handler', '@kernel', '@database', '@update.update_hook_registry', '@logger.factory'] tags: - { name: service_collector, tag: 'module_install.uninstall_validator', call: addUninstallValidator } diff --git a/composer.json b/composer.json index bb28e01c..65b53f38 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,7 @@ "homepage": "http://drupal.org/project/civicrm_entity", "license": "GPL-2.0+", "require": { - "drupal/core": "^10 || ^11", + "drupal/core": "^10.1 || ^11", "civicrm/civicrm-drupal-8": "*" }, "require-dev": { diff --git a/src/ModuleInstaller.php b/src/ModuleInstaller.php index 6f96d8e7..f9f892cb 100644 --- a/src/ModuleInstaller.php +++ b/src/ModuleInstaller.php @@ -7,6 +7,7 @@ use Drupal\Core\Extension\ModuleInstaller as ExtensionModuleInstaller; use Drupal\Core\Extension\ModuleInstallerInterface; use Drupal\Core\Database\Connection; +use Drupal\Core\Logger\LoggerChannelFactory; use Drupal\Core\Update\UpdateHookRegistry; /** @@ -24,8 +25,9 @@ class ModuleInstaller extends ExtensionModuleInstaller { /** * {@inheritdoc} */ - public function __construct(ModuleInstallerInterface $module_installer, $root, ModuleHandlerInterface $module_handler, DrupalKernelInterface $kernel, Connection $connection, UpdateHookRegistry $update_registry) { - parent::__construct($root, $module_handler, $kernel, $connection, $update_registry); + public function __construct(ModuleInstallerInterface $module_installer, $root, ModuleHandlerInterface $module_handler, DrupalKernelInterface $kernel, Connection $connection, UpdateHookRegistry $update_registry, LoggerChannelFactory $logger_factory) { + $logger = $logger_factory->get('civicrm_entity'); + parent::__construct($root, $module_handler, $kernel, $connection, $update_registry, $logger); $this->moduleInstaller = $module_installer; } From 7464e4644493475404132819ea1fb6bb16b31e90 Mon Sep 17 00:00:00 2001 From: Mark Hanna Date: Mon, 20 May 2024 16:37:06 -0600 Subject: [PATCH 07/15] update settings form for D11 compatibility (#485) --- src/Form/CivicrmEntitySettings.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Form/CivicrmEntitySettings.php b/src/Form/CivicrmEntitySettings.php index 94459743..41c56852 100644 --- a/src/Form/CivicrmEntitySettings.php +++ b/src/Form/CivicrmEntitySettings.php @@ -5,6 +5,7 @@ use Drupal\civicrm_entity\SupportedEntities; use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Config\ConfigFactoryInterface; +use Drupal\Core\Config\TypedConfigManagerInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Form\ConfigFormBase; use Drupal\Core\Form\FormStateInterface; @@ -67,6 +68,8 @@ class CivicrmEntitySettings extends ConfigFormBase { * * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory * The factory for configuration objects. + * @param \Drupal\Core\Config\TypedConfigManagerInterface $typedConfigManager + * The typed config manager. * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager * The entity type manager. * @param \Drupal\Core\Routing\RouteBuilderInterface $route_builder @@ -80,8 +83,8 @@ class CivicrmEntitySettings extends ConfigFormBase { * @param \Drupal\Core\Cache\CacheBackendInterface $cache_render * The render cache manager. */ - public function __construct(ConfigFactoryInterface $config_factory, EntityTypeManagerInterface $entity_type_manager, RouteBuilderInterface $route_builder, LocalActionManager $local_action_manager, LocalTaskManager $local_task_manager, MenuLinkManagerInterface $menu_link_manager, CacheBackendInterface $cache_render) { - parent::__construct($config_factory); + public function __construct(ConfigFactoryInterface $config_factory, TypedConfigManagerInterface $typedConfigManager, EntityTypeManagerInterface $entity_type_manager, RouteBuilderInterface $route_builder, LocalActionManager $local_action_manager, LocalTaskManager $local_task_manager, MenuLinkManagerInterface $menu_link_manager, CacheBackendInterface $cache_render) { + parent::__construct($config_factory, $typedConfigManager); $this->entityTypeManager = $entity_type_manager; $this->routeBuilder = $route_builder; $this->localActionManager = $local_action_manager; @@ -96,6 +99,7 @@ public function __construct(ConfigFactoryInterface $config_factory, EntityTypeMa public static function create(ContainerInterface $container) { return new static( $container->get('config.factory'), + $container->get('config.typed'), $container->get('entity_type.manager'), $container->get('router.builder'), $container->get('plugin.manager.menu.local_action'), From fa0bd3cdb6a9de8894b0960c1152bef8e70b6184 Mon Sep 17 00:00:00 2001 From: puresyntax71 <34715246+puresyntax71@users.noreply.github.com> Date: Wed, 22 May 2024 01:01:39 +0800 Subject: [PATCH 08/15] Fix metatag not loading. (#481) * Fix metatag not loading. * Trigger test. * Only target metatag_computed. --- src/CiviEntityStorage.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/CiviEntityStorage.php b/src/CiviEntityStorage.php index e76bc252..fd703006 100644 --- a/src/CiviEntityStorage.php +++ b/src/CiviEntityStorage.php @@ -416,6 +416,10 @@ protected function initFieldValues(ContentEntityInterface $entity, array $values $civicrm_entity_settings = $this->getConfigFactory()->get('civicrm_entity.settings'); $field_definitions = $entity->getFieldDefinitions(); foreach ($field_definitions as $definition) { + if ($definition->getType() == 'metatag_computed') { + continue; + } + $items = $entity->get($definition->getName()); if ($items->isEmpty()) { continue; From 407ef9b4c535d3f85ca317823218cc12088ea64b Mon Sep 17 00:00:00 2001 From: puresyntax71 <34715246+puresyntax71@users.noreply.github.com> Date: Wed, 22 May 2024 02:22:59 +0800 Subject: [PATCH 09/15] Add patch from https://www.drupal.org/project/civicrm_entity/issues/3447309. (#486) --- civicrm_entity.module | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/civicrm_entity.module b/civicrm_entity.module index 12176250..73fa6a26 100644 --- a/civicrm_entity.module +++ b/civicrm_entity.module @@ -487,7 +487,12 @@ function civicrm_entity_civicrm_pre($op, $objectName, $id, &$params) { else { // Special handling for EntityTag objects. if ($objectName == 'EntityTag') { - $id = $storage->getEntityTagEntityId($params[0][0], $params[1]); + if (isset($params['entity_id']) && isset($params['entity_table'])) { + $id = $storage->getEntityTagEntityId($params['entity_id'], $params['entity_table']); + } + else { + $id = $storage->getEntityTagEntityId($params[0][0], $params[1]); + } } /** @var \Drupal\civicrm_entity\Entity\CivicrmEntity $entity */ $entity = $storage->load($id); From f10bb4204fdd24ec50a35c1e1d3e54d329457473 Mon Sep 17 00:00:00 2001 From: Mark Hanna Date: Thu, 30 May 2024 09:26:30 -0600 Subject: [PATCH 10/15] fix edge case updating base field definition for bundles (#487) * fix edge case updating base field definition for bundles * trigger tests --- civicrm_entity.module | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/civicrm_entity.module b/civicrm_entity.module index 73fa6a26..c27b2ef1 100644 --- a/civicrm_entity.module +++ b/civicrm_entity.module @@ -238,12 +238,14 @@ function civicrm_entity_entity_bundle_field_info(EntityTypeInterface $entity_typ } } // Ensure all fields have a definition. - foreach ($base_field_definitions as $field_name => $definition) { - if (isset($result[$field_name])) { - continue; + if ($entity_type->get('civicrm_entity_ui_exposed') && $entity_type->hasKey('bundle')) { + foreach ($base_field_definitions as $field_name => $definition) { + if (isset($result[$field_name])) { + continue; + } + $field = BaseFieldOverride::createFromBaseFieldDefinition($base_field_definitions[$field_name], $bundle); + $result[$field_name] = $field; } - $field = BaseFieldOverride::createFromBaseFieldDefinition($base_field_definitions[$field_name], $bundle); - $result[$field_name] = $field; } return $result; } From 2ab4087e03a96c3ac0228a082d675ac76b2ddb17 Mon Sep 17 00:00:00 2001 From: Mark Hanna Date: Fri, 31 May 2024 08:32:36 -0600 Subject: [PATCH 11/15] update tests for 10.3 and 11 (#484) * update tests for 10.3 and 11 * versions * versions * rerun tests post core PRs merged * try demeritcowboy's changes to tests * try different php versions per drupal/civi combination --- .github/workflows/main.yml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 169ba9c4..15e79e2c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,8 +17,13 @@ jobs: include: - drupal: '10.2.*' civicrm: '5.69.*' - - drupal: '10.2.*' + php: '8.1' + - drupal: '10.3.0-beta1@beta' + civicrm: 'dev-master' + php: '8.3' + - drupal: '11.0.0-beta1@beta' civicrm: 'dev-master' + php: '8.3' name: Drupal ${{ matrix.drupal }} | CiviCRM ${{ matrix.civicrm }} services: mysql: @@ -36,7 +41,7 @@ jobs: - uses: actions/checkout@v2 - uses: shivammathur/setup-php@v2 with: - php-version: 8.1 + php-version: ${{ matrix.php }} extensions: dom, curl, libxml, mbstring, zip, pdo, mysql, pdo_mysql, bcmath, soap, intl, gd, exif, iconv coverage: none tools: composer:v2 @@ -90,7 +95,7 @@ jobs: run: php -S 127.0.0.1:8080 -t ~/drupal/web & - name: Run PHPUnit run: | - mkdir $BROWSERTEST_OUTPUT_DIRECTORY + mkdir -p $BROWSERTEST_OUTPUT_DIRECTORY cd ~/drupal/web ../vendor/bin/phpunit -c core modules/contrib/civicrm_entity env: @@ -98,8 +103,8 @@ jobs: SIMPLETEST_DB: mysql://root:@127.0.0.1:${{ job.services.mysql.ports[3306] }}/db SIMPLETEST_CIVICRM_DB: mysql://root:@127.0.0.1:${{ job.services.mysql.ports[3306] }}/db_civicrm SIMPLETEST_BASE_URL: http://127.0.0.1:8080 - MINK_DRIVER_ARGS_WEBDRIVER: '["chrome", {"browserName":"chrome","chromeOptions":{"args":["--disable-gpu", "--no-sandbox", "--headless"]}}, "http://127.0.0.1:9515"]' - BROWSERTEST_OUTPUT_DIRECTORY: '${{ runner.temp }}/browser_output' + MINK_DRIVER_ARGS_WEBDRIVER: '["chrome", {"browserName":"chrome","goog:chromeOptions":{"args":["--disable-gpu", "--no-sandbox", "--headless"]}}, "http://127.0.0.1:9515"]' + BROWSERTEST_OUTPUT_DIRECTORY: '/home/runner/drupal/web/sites/simpletest/browser_output' - uses: actions/upload-artifact@v2 if: ${{ failure() || success() }} with: From a46f9f7f0caa2d9e8e9a7e0e961dcbd5ff58d9e7 Mon Sep 17 00:00:00 2001 From: Mark Hanna Date: Tue, 11 Jun 2024 10:55:34 -0600 Subject: [PATCH 12/15] use LoggerChannelFactoryInterface instead of default service (#488) --- src/ModuleInstaller.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ModuleInstaller.php b/src/ModuleInstaller.php index f9f892cb..8a5a751e 100644 --- a/src/ModuleInstaller.php +++ b/src/ModuleInstaller.php @@ -7,7 +7,7 @@ use Drupal\Core\Extension\ModuleInstaller as ExtensionModuleInstaller; use Drupal\Core\Extension\ModuleInstallerInterface; use Drupal\Core\Database\Connection; -use Drupal\Core\Logger\LoggerChannelFactory; +use Drupal\Core\Logger\LoggerChannelFactoryInterface; use Drupal\Core\Update\UpdateHookRegistry; /** @@ -25,7 +25,7 @@ class ModuleInstaller extends ExtensionModuleInstaller { /** * {@inheritdoc} */ - public function __construct(ModuleInstallerInterface $module_installer, $root, ModuleHandlerInterface $module_handler, DrupalKernelInterface $kernel, Connection $connection, UpdateHookRegistry $update_registry, LoggerChannelFactory $logger_factory) { + public function __construct(ModuleInstallerInterface $module_installer, $root, ModuleHandlerInterface $module_handler, DrupalKernelInterface $kernel, Connection $connection, UpdateHookRegistry $update_registry, LoggerChannelFactoryInterface $logger_factory) { $logger = $logger_factory->get('civicrm_entity'); parent::__construct($root, $module_handler, $kernel, $connection, $update_registry, $logger); $this->moduleInstaller = $module_installer; From 0b7d9dca828018620c2ff9f1120b8acdf361494c Mon Sep 17 00:00:00 2001 From: Mark Hanna Date: Tue, 9 Jul 2024 17:08:16 -0600 Subject: [PATCH 13/15] check for metatag_computed field, for Drupal entity based saves with Metatag 2.0 (#489) --- src/Entity/CivicrmEntity.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Entity/CivicrmEntity.php b/src/Entity/CivicrmEntity.php index dcbeeafa..67e741e5 100644 --- a/src/Entity/CivicrmEntity.php +++ b/src/Entity/CivicrmEntity.php @@ -201,6 +201,10 @@ public function civicrmApiNormalize() { continue; } + if ($storage_definition->getType() == 'metatag_computed') { + continue; + } + $main_property_name = $storage_definition->getMainPropertyName(); $list = []; /** @var \Drupal\Core\Field\FieldItemInterface $item */ From ccc3d749f0fc1d66aaa9a6098c308be8f93b9bd1 Mon Sep 17 00:00:00 2001 From: Mark Hanna Date: Tue, 9 Jul 2024 17:08:34 -0600 Subject: [PATCH 14/15] update tests, 10.3 official, and 5.75 (#490) --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 15e79e2c..ccb49b5b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -18,8 +18,8 @@ jobs: - drupal: '10.2.*' civicrm: '5.69.*' php: '8.1' - - drupal: '10.3.0-beta1@beta' - civicrm: 'dev-master' + - drupal: '10.3.*' + civicrm: '5.75.*' php: '8.3' - drupal: '11.0.0-beta1@beta' civicrm: 'dev-master' From 2bfacc15014b39a9f781afbe8889bcb3baed0a56 Mon Sep 17 00:00:00 2001 From: puresyntax71 <34715246+puresyntax71@users.noreply.github.com> Date: Sat, 10 Aug 2024 03:56:40 +0800 Subject: [PATCH 15/15] Support for basefield overrides (#496) * Override bundle when base_field_override_ui exists. * Let basefield overrides handle field definitions. --------- Co-authored-by: Arnold French --- civicrm_entity.module | 2 +- src/Routing/RouteSubscriber.php | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/civicrm_entity.module b/civicrm_entity.module index c27b2ef1..9b3a0341 100644 --- a/civicrm_entity.module +++ b/civicrm_entity.module @@ -240,7 +240,7 @@ function civicrm_entity_entity_bundle_field_info(EntityTypeInterface $entity_typ // Ensure all fields have a definition. if ($entity_type->get('civicrm_entity_ui_exposed') && $entity_type->hasKey('bundle')) { foreach ($base_field_definitions as $field_name => $definition) { - if (isset($result[$field_name])) { + if (isset($result[$field_name]) || isset($definition)) { continue; } $field = BaseFieldOverride::createFromBaseFieldDefinition($base_field_definitions[$field_name], $bundle); diff --git a/src/Routing/RouteSubscriber.php b/src/Routing/RouteSubscriber.php index 9c3a7446..e295620f 100644 --- a/src/Routing/RouteSubscriber.php +++ b/src/Routing/RouteSubscriber.php @@ -147,6 +147,24 @@ protected function alterRoutes(RouteCollection $collection) { ]; } + if ($this->moduleHandler->moduleExists('base_field_override_ui')) { + $field_ui_routes["entity.base_field_override.{$entity_type_id}_base_field_override_add_form"] = [ + 'bundle' => $entity_type_id, + ]; + + $field_ui_routes["entity.base_field_override.{$entity_type_id}_base_field_override_add_form"] = [ + 'bundle' => $entity_type_id, + ]; + + $field_ui_routes["entity.base_field_override.{$entity_type_id}_base_field_override_edit_form"] = [ + 'bundle' => $entity_type_id, + ]; + + $field_ui_routes["entity.base_field_override.{$entity_type_id}.base_field_override_ui_fields"] = [ + 'bundle' => $entity_type_id, + ]; + } + foreach ($field_ui_routes as $route_name => $defaults) { $route = $collection->get($route_name);