Skip to content
Snippets Groups Projects
Commit a85abc52 authored by Dieter Holvoet's avatar Dieter Holvoet
Browse files

Issue #3367954 by DieterHolvoet: Add support for ECK 2.0

parent 8e8ea1d9
No related branches found
No related tags found
1 merge request!7Issue #3367954: Add support for ECK 2.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
}
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
......
<?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;
}
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment