diff --git a/CHANGELOG.md b/CHANGELOG.md index 9878f2d..81b8d54 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Stanford Migrate +8.x-1.1 +-------------------------------------------------------------------------------- +_Release Date: 2020-07-13_ + +- D8CORE-000: Fix cron job creator (#6) (01c8767) + 8.x-1.0 -------------------------------------------------------------------------------- _Release Date: 2020-06-17_ diff --git a/src/Form/StanfordMigrateUltimateCronForm.php b/src/Form/StanfordMigrateUltimateCronForm.php index b895a35..d4317dc 100644 --- a/src/Form/StanfordMigrateUltimateCronForm.php +++ b/src/Form/StanfordMigrateUltimateCronForm.php @@ -5,7 +5,6 @@ use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Form\FormBase; use Drupal\Core\Form\FormStateInterface; -use Drupal\migrate\Plugin\MigrationPluginManager; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -15,13 +14,6 @@ */ class StanfordMigrateUltimateCronForm extends FormBase { - /** - * Migration plugin manager service. - * - * @var \Drupal\migrate\Plugin\MigrationPluginManager - */ - protected $migrationManager; - /** * Entity type manager service. * @@ -34,7 +26,6 @@ class StanfordMigrateUltimateCronForm extends FormBase { */ public static function create(ContainerInterface $container) { return new static( - $container->get('plugin.manager.migration'), $container->get('entity_type.manager') ); } @@ -42,13 +33,10 @@ public static function create(ContainerInterface $container) { /** * StanfordMigrateUltimateCronForm constructor. * - * @param \Drupal\migrate\Plugin\MigrationPluginManager $migration_manager - * Migration plugin manager service. * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager * Entity type manager service. */ - public function __construct(MigrationPluginManager $migration_manager, EntityTypeManagerInterface $entity_type_manager) { - $this->migrationManager = $migration_manager; + public function __construct(EntityTypeManagerInterface $entity_type_manager) { $this->entityTypeManager = $entity_type_manager; } @@ -68,12 +56,16 @@ public function buildForm(array $form, FormStateInterface $form_state) { $existing_migration_jobs = []; $missing_migration_jobs = []; - foreach ($this->migrationManager->getDefinitions() as $migration_id => $definition) { - if (in_array("ultimate_cron.job.stanford_migrate_$migration_id", $existing_configs)) { - $existing_migration_jobs[$migration_id] = $definition['label']; + + $migration_group_configs = $this->configFactory->listAll('migrate_plus.migration_group.'); + foreach ($migration_group_configs as $config_name) { + $group_config = $this->config($config_name); + $migration_group = $group_config->get('id'); + if (in_array("ultimate_cron.job.stanford_migrate_$migration_group", $existing_configs)) { + $existing_migration_jobs[$migration_group] = $group_config->get('label'); continue; } - $missing_migration_jobs[$migration_id] = $definition['label']; + $missing_migration_jobs[$migration_group] = $group_config->get('label'); } $form_state->set('missing_cron_jobs', $missing_migration_jobs); @@ -101,9 +93,9 @@ public function buildForm(array $form, FormStateInterface $form_state) { * {@inheritDoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { - foreach ($form_state->get('missing_cron_jobs') as $migration_id => $label) { + foreach ($form_state->get('missing_cron_jobs') as $group_id => $label) { $values = [ - 'id' => "stanford_migrate_$migration_id", + 'id' => "stanford_migrate_$group_id", 'title' => 'Importer: ' . $label, 'callback' => 'stanford_migrate_ultimate_cron_task', 'module' => 'stanford_migrate', @@ -112,7 +104,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { ->create($values)->save(); } $this->messenger() - ->addStatus($this->t('Created cron jobs for the following migration entities: %labels', ['%labels' => implode(',', $form_state->get('missing_cron_jobs'))])); + ->addStatus($this->t('Created cron jobs for the following migration entities: %labels', ['%labels' => implode(', ', $form_state->get('missing_cron_jobs'))])); } } diff --git a/stanford_migrate.info.yml b/stanford_migrate.info.yml index 5251281..f2f345b 100755 --- a/stanford_migrate.info.yml +++ b/stanford_migrate.info.yml @@ -3,7 +3,7 @@ description: 'Adds more functionality to migrate and migrate plus modules' type: module core_version_requirement: ^8.8 || ^9 package: 'Stanford' -version: 8.x-1.0 +version: 8.x-1.1 dependencies: - drupal:migrate - migrate_plus:migrate_plus diff --git a/stanford_migrate.links.task.yml b/stanford_migrate.links.task.yml new file mode 100644 index 0000000..dc3271b --- /dev/null +++ b/stanford_migrate.links.task.yml @@ -0,0 +1,4 @@ +stanford_migrate.ultimate_cron: + title: 'Migrations' + route_name: stanford_migrate.ultimate_cron + base_route: entity.ultimate_cron_job.collection diff --git a/stanford_migrate.routing.yml b/stanford_migrate.routing.yml index 83959e5..240b3fe 100644 --- a/stanford_migrate.routing.yml +++ b/stanford_migrate.routing.yml @@ -9,7 +9,7 @@ stanford_migrate.list: _custom_access: '\Drupal\stanford_migrate\Form\StanfordMigrateImportForm::access' stanford_migrate.ultimate_cron: - path: '/admin/config/importers/ultimate-cron' + path: '/admin/config/system/cron/migrate-jobs' defaults: _form: '\Drupal\stanford_migrate\Form\StanfordMigrateUltimateCronForm' _title: 'Importer Cron Jobs'