diff --git a/composer.json b/composer.json deleted file mode 100644 index cef32429f49bc57a15fe7444e5f36698d8f10d0e..0000000000000000000000000000000000000000 --- a/composer.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "name": "drupal/scheduler_eck", - "description": "Integrates the Scheduler and Entity Construction Kit (ECK) modules", - "license": "GPL-2.0-or-later", - "type": "drupal-module", - "require": { - "php": "^7.1 || ^8.0", - "drupal/eck": "^1.0", - "drupal/scheduler": "^2.0.0-rc4", - "drupal/core": "^8.8.3 || ^9.0 || ^10" - }, - "require-dev": { - "composer-runtime-api": "^2.0" - }, - "repositories": { - "drupal": { - "type": "composer", - "url": "https://packages.drupal.org/8" - } - }, - "minimum-stability": "dev", - "prefer-stable": true -} diff --git a/scheduler_eck.info.yml b/scheduler_eck.info.yml index e2c111db67d73dc4c0f540396b215d03cb178908..617c836552375dda9c10e493d0057593e4459642 100644 --- a/scheduler_eck.info.yml +++ b/scheduler_eck.info.yml @@ -1,7 +1,8 @@ name: Scheduler for Entity Construction Kit (ECK) type: module description: Integrates the Scheduler and Entity Construction Kit (ECK) modules. -core_version_requirement: ^8 || ^9 || ^10 +core_version_requirement: ^8.8.3 || ^9 || ^10 +php: 7.1 dependencies: - drupal:system (>= 8.8.3) - eck:eck diff --git a/scheduler_eck.install b/scheduler_eck.install new file mode 100644 index 0000000000000000000000000000000000000000..f715ebc7384dcef608c5a7c6324092a45bd53782 --- /dev/null +++ b/scheduler_eck.install @@ -0,0 +1,30 @@ +<?php + +/** + * @file + * Hook implementations dealing with installation and updates. + */ + +/** + * Implements hook_help(). + */ +function scheduler_eck_requirements(string $phase): array { + $requirements = []; + $entityKeys = \Drupal::entityTypeManager() + ->getDefinition('eck_entity_type') + ->get('entity_keys'); + + if (!isset($entityKeys['published'])) { + $requirements['eck_status_field'] = [ + 'title' => t('ECK Status Field'), + 'value' => t('ECK entities should have the ability to have a status field.'), + 'description' => t('Update the <a href=":eckModuleLink">Entity Construction Kit (ECK) module</a> to version 2 or above or install the <a href=":eckStatusFieldModuleLink">ECK Status Field module.</a>', [ + ':eckModuleLink' => 'https://www.drupal.org/project/eck', + ':eckStatusFieldModuleLink' => 'https://www.drupal.org/project/eck_status_field', + ]), + 'severity' => REQUIREMENT_ERROR, + ]; + } + + return $requirements; +} diff --git a/src/Plugin/Derivative/SchedulerEckDeriver.php b/src/Plugin/Derivative/SchedulerEckDeriver.php index 8ea297ed8badacf78c2fc06c1f763eac12e1220a..8322cbf9dfac010b101001eb8ab24ae461567f11 100644 --- a/src/Plugin/Derivative/SchedulerEckDeriver.php +++ b/src/Plugin/Derivative/SchedulerEckDeriver.php @@ -39,28 +39,28 @@ class SchedulerEckDeriver extends DeriverBase implements ContainerDeriverInterfa return $this->derivatives; } - $storage = $this->entityTypeManager - ->getStorage('eck_entity_type'); + $entityTypes = $this->entityTypeManager + ->getStorage('eck_entity_type') + ->loadMultiple(); - $query = $storage->getQuery(); - $ids = $query - ->condition($query->orConditionGroup() - ->condition('published', 1) - ->condition('published', TRUE)) - ->execute(); + foreach ($entityTypes as $entityType) { + $derivativeKey = sprintf('%s:%s', $base_plugin_definition['id'], $entityType->id()); + $definition = $this->entityTypeManager->getDefinition($entityType->id()); + $statusFieldName = $definition->getKey('published'); + + if (!$entityType->get($statusFieldName)) { + continue; + } - foreach ($ids as $eck_type_id) { - $derivative_key = sprintf('%s:%s', $base_plugin_definition['id'], $eck_type_id); - $eck_type = $storage->load($eck_type_id); $description = $this->t('Provides support for scheduling @entityType entities', [ - '@entityType' => $eck_type->label(), + '@entityType' => $entityType->label(), ]); - $this->derivatives[$eck_type_id] = $base_plugin_definition; - $this->derivatives[$eck_type_id]['id'] = $derivative_key; - $this->derivatives[$eck_type_id]['label'] = $eck_type->label(); - $this->derivatives[$eck_type_id]['description'] = $description; - $this->derivatives[$eck_type_id]['entityType'] = $eck_type_id; + $this->derivatives[$entityType->id()] = $base_plugin_definition; + $this->derivatives[$entityType->id()]['id'] = $derivativeKey; + $this->derivatives[$entityType->id()]['label'] = $entityType->label(); + $this->derivatives[$entityType->id()]['description'] = $description; + $this->derivatives[$entityType->id()]['entityType'] = $entityType->id(); } return $this->derivatives;