From 83f89c2ad3fb6e5504230b17fd1cf84936794a6f Mon Sep 17 00:00:00 2001 From: JojoVes Date: Wed, 29 May 2024 14:07:27 -0300 Subject: [PATCH 1/7] update drush command namespaces --- drush.services.yml | 4 ++-- src/{ => Drush}/Commands/Generate.php | 2 +- src/{ => Drush}/Commands/PrintMissingEntityIds.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) rename src/{ => Drush}/Commands/Generate.php (99%) rename src/{ => Drush}/Commands/PrintMissingEntityIds.php (98%) diff --git a/drush.services.yml b/drush.services.yml index fe76863..c2eef6b 100644 --- a/drush.services.yml +++ b/drush.services.yml @@ -1,6 +1,6 @@ services: dgi_actions.commands: - class: \Drupal\dgi_actions\Commands\Generate + class: \Drupal\dgi_actions\Drush\Commands\Generate arguments: [ '@http_client', '@entity_type.manager', @@ -12,7 +12,7 @@ services: tags: - { name: drush.command } dgi_actions.print_missing_identifier_entity_ids: - class: \Drupal\dgi_actions\Commands\PrintMissingEntityIds + class: \Drupal\dgi_actions\Drush\Commands\PrintMissingEntityIds arguments: [ '@entity_type.manager', '@dgi_actions.utils' diff --git a/src/Commands/Generate.php b/src/Drush/Commands/Generate.php similarity index 99% rename from src/Commands/Generate.php rename to src/Drush/Commands/Generate.php index 5205747..fe81f44 100644 --- a/src/Commands/Generate.php +++ b/src/Drush/Commands/Generate.php @@ -1,6 +1,6 @@ Date: Wed, 29 May 2024 14:57:16 -0300 Subject: [PATCH 2/7] use logger.channel.dgi_actions --- drush.services.yml | 5 +---- src/Drush/Commands/Generate.php | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/drush.services.yml b/drush.services.yml index c2eef6b..708e827 100644 --- a/drush.services.yml +++ b/drush.services.yml @@ -7,7 +7,7 @@ services: '@dgi_actions.utils', '@dgi_actions.dgiutils', '@islandora.utils', - '@logger.dgi_actions' + '@logger.channel.dgi_actions' ] tags: - { name: drush.command } @@ -19,6 +19,3 @@ services: ] tags: - { name: drush.command } - logger.dgi_actions: - parent: logger.channel_base - arguments: [ 'dgi_actions' ] diff --git a/src/Drush/Commands/Generate.php b/src/Drush/Commands/Generate.php index fe81f44..972e893 100644 --- a/src/Drush/Commands/Generate.php +++ b/src/Drush/Commands/Generate.php @@ -14,6 +14,7 @@ use Drush\Commands\DrushCommands; use GuzzleHttp\ClientInterface; use Psr\Log\LoggerInterface; +use Symfony\Component\DependencyInjection\ContainerInterface; /** * Drush commands for generating identifiers for existing objects. @@ -90,6 +91,19 @@ public function __construct(ClientInterface $client, EntityTypeManagerInterface $this->ourLogger = $logger; } + /** + * {@inheritDoc} + */ + public static function create(ContainerInterface $container) : self { + return new static( + $container->get('http_client'), + $container->get('entity_type.manager'), + $container->get('dgi_actions.utils'), + $container->get('islandora.utils'), + $container->get('logger.channel.dgi_actions') + ); + } + /** * Generates missing identifiers for entities. * From 4c65606add234aad3fbaae54d10eb465547ec3af Mon Sep 17 00:00:00 2001 From: JojoVes Date: Wed, 29 May 2024 16:01:41 -0300 Subject: [PATCH 3/7] more namespacing and create() method addition --- modules/dgi_actions_handle/drush.services.yml | 2 +- .../src/{ => Drush}/Commands/HandleCommands.php | 14 +++++++++++++- .../src/{ => Drush}/Commands/Update.php | 0 src/Drush/Commands/PrintMissingEntityIds.php | 11 +++++++++++ 4 files changed, 25 insertions(+), 2 deletions(-) rename modules/dgi_actions_handle/src/{ => Drush}/Commands/HandleCommands.php (92%) rename modules/dgi_actions_handle/src/{ => Drush}/Commands/Update.php (100%) diff --git a/modules/dgi_actions_handle/drush.services.yml b/modules/dgi_actions_handle/drush.services.yml index bfc39e7..6ce5967 100644 --- a/modules/dgi_actions_handle/drush.services.yml +++ b/modules/dgi_actions_handle/drush.services.yml @@ -1,7 +1,7 @@ --- services: dgi_actions_handle.commands: - class: \Drupal\dgi_actions_handle\Commands\HandleCommands + class: \Drupal\dgi_actions_handle\Drush\Commands\HandleCommands arguments: ['@http_client', '@entity_type.manager', '@dgi_actions.utils'] tags: - { name: drush.command } diff --git a/modules/dgi_actions_handle/src/Commands/HandleCommands.php b/modules/dgi_actions_handle/src/Drush/Commands/HandleCommands.php similarity index 92% rename from modules/dgi_actions_handle/src/Commands/HandleCommands.php rename to modules/dgi_actions_handle/src/Drush/Commands/HandleCommands.php index db4ebaa..06cd67c 100644 --- a/modules/dgi_actions_handle/src/Commands/HandleCommands.php +++ b/modules/dgi_actions_handle/src/Drush/Commands/HandleCommands.php @@ -1,6 +1,6 @@ utils = $utils; } + /** + * {@inheritDoc} + */ + public static function create(ContainerInterface $container) : self { + return new static( + $container->get('http_client'), + $container->get('entity_type.manager'), + $container->get('dgi_actions.utils') + ); + } + /** * Validates the update command. * diff --git a/modules/dgi_actions_handle/src/Commands/Update.php b/modules/dgi_actions_handle/src/Drush/Commands/Update.php similarity index 100% rename from modules/dgi_actions_handle/src/Commands/Update.php rename to modules/dgi_actions_handle/src/Drush/Commands/Update.php diff --git a/src/Drush/Commands/PrintMissingEntityIds.php b/src/Drush/Commands/PrintMissingEntityIds.php index 2cb511a..143c7b5 100644 --- a/src/Drush/Commands/PrintMissingEntityIds.php +++ b/src/Drush/Commands/PrintMissingEntityIds.php @@ -8,6 +8,7 @@ use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\dgi_actions\Utility\IdentifierUtils; use Drush\Commands\DrushCommands; +use Symfony\Component\DependencyInjection\ContainerInterface; /** * Drush commands for generating identifiers for existing objects. @@ -45,6 +46,16 @@ public function __construct(EntityTypeManagerInterface $entity_type_manager, Ide $this->identifierUtils = $identifier_utils; } + /** + * {@inheritDoc} + */ + public static function create(ContainerInterface $container) : self { + return new static( + $container->get('entity_type.manager'), + $container->get('dgi_actions.utils') + ); + } + /** * Prints entity IDs with missing identifiers. * From 4debe7a2068760548d103c6ea46806a762009dff Mon Sep 17 00:00:00 2001 From: JojoVes Date: Wed, 29 May 2024 16:06:36 -0300 Subject: [PATCH 4/7] alphabetize use statements --- .../src/Plugin/Action/DeleteArkIdentifier.php | 2 +- src/Form/DataProfileDeleteForm.php | 2 +- src/Plugin/Action/IdentifierAction.php | 12 ++++++------ src/Plugin/Action/MintIdentifier.php | 2 +- src/Plugin/Condition/EntityHasIdentifier.php | 6 +++--- src/Plugin/DataProfileManager.php | 2 +- src/Plugin/ServiceDataTypeManager.php | 2 +- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/modules/dgi_actions_ark_identifier/src/Plugin/Action/DeleteArkIdentifier.php b/modules/dgi_actions_ark_identifier/src/Plugin/Action/DeleteArkIdentifier.php index f925a28..fb41b4f 100644 --- a/modules/dgi_actions_ark_identifier/src/Plugin/Action/DeleteArkIdentifier.php +++ b/modules/dgi_actions_ark_identifier/src/Plugin/Action/DeleteArkIdentifier.php @@ -3,10 +3,10 @@ namespace Drupal\dgi_actions_ark_identifier\Plugin\Action; use Drupal\Core\Entity\EntityTypeManagerInterface; -use Drupal\dgi_actions_ezid\Utility\EzidTrait; use Drupal\dgi_actions\Plugin\Action\DeleteIdentifier; use Drupal\dgi_actions\Plugin\Action\HttpActionDeleteTrait; use Drupal\dgi_actions\Utility\IdentifierUtils; +use Drupal\dgi_actions_ezid\Utility\EzidTrait; use GuzzleHttp\ClientInterface; use GuzzleHttp\RequestOptions; use Psr\Http\Message\ResponseInterface; diff --git a/src/Form/DataProfileDeleteForm.php b/src/Form/DataProfileDeleteForm.php index 2bc2a18..6d109c3 100644 --- a/src/Form/DataProfileDeleteForm.php +++ b/src/Form/DataProfileDeleteForm.php @@ -4,8 +4,8 @@ use Drupal\Core\Entity\EntityConfirmFormBase; use Drupal\Core\Form\FormStateInterface; -use Drupal\Core\Url; use Drupal\Core\StringTranslation\TranslatableMarkup; +use Drupal\Core\Url; /** * Builds the form to delete Data Profile setting entities. diff --git a/src/Plugin/Action/IdentifierAction.php b/src/Plugin/Action/IdentifierAction.php index eafa4be..3f656a6 100644 --- a/src/Plugin/Action/IdentifierAction.php +++ b/src/Plugin/Action/IdentifierAction.php @@ -2,16 +2,16 @@ namespace Drupal\dgi_actions\Plugin\Action; -use Drupal\Core\Entity\EntityTypeManagerInterface; -use Drupal\dgi_actions\Entity\IdentifierInterface; -use Drupal\dgi_actions\Utility\IdentifierUtils; use Drupal\Core\Action\ConfigurableActionBase; -use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Entity\EntityInterface; +use Drupal\Core\Entity\EntityTypeManagerInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; -use Symfony\Component\DependencyInjection\ContainerInterface; -use Psr\Log\LoggerInterface; use Drupal\Core\Session\AccountInterface; +use Drupal\dgi_actions\Entity\IdentifierInterface; +use Drupal\dgi_actions\Utility\IdentifierUtils; +use Psr\Log\LoggerInterface; +use Symfony\Component\DependencyInjection\ContainerInterface; /** * Base class for Identifier Actions. diff --git a/src/Plugin/Action/MintIdentifier.php b/src/Plugin/Action/MintIdentifier.php index 8b36cca..02b66d6 100644 --- a/src/Plugin/Action/MintIdentifier.php +++ b/src/Plugin/Action/MintIdentifier.php @@ -2,8 +2,8 @@ namespace Drupal\dgi_actions\Plugin\Action; -use Drupal\Core\Entity\FieldableEntityInterface; use Drupal\Core\Entity\Exception\UndefinedLinkTemplateException; +use Drupal\Core\Entity\FieldableEntityInterface; use Drupal\Core\Field\EntityReferenceFieldItemList; use Drupal\Core\Form\FormStateInterface; diff --git a/src/Plugin/Condition/EntityHasIdentifier.php b/src/Plugin/Condition/EntityHasIdentifier.php index 6fa6873..8652220 100644 --- a/src/Plugin/Condition/EntityHasIdentifier.php +++ b/src/Plugin/Condition/EntityHasIdentifier.php @@ -6,12 +6,12 @@ use Drupal\Core\Condition\ConditionPluginBase; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Entity\FieldableEntityInterface; -use Drupal\Core\StringTranslation\StringTranslationTrait; -use Drupal\Core\Plugin\ContainerFactoryPluginInterface; -use Symfony\Component\DependencyInjection\ContainerInterface; use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\Plugin\ContainerFactoryPluginInterface; +use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\dgi_actions\Utility\IdentifierUtils; use Psr\Log\LoggerInterface; +use Symfony\Component\DependencyInjection\ContainerInterface; /** * Condition to check an Entity for an existing persistent identifier. diff --git a/src/Plugin/DataProfileManager.php b/src/Plugin/DataProfileManager.php index 38bad1b..4ffd01e 100644 --- a/src/Plugin/DataProfileManager.php +++ b/src/Plugin/DataProfileManager.php @@ -2,9 +2,9 @@ namespace Drupal\dgi_actions\Plugin; -use Drupal\Core\Plugin\DefaultPluginManager; use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Extension\ModuleHandlerInterface; +use Drupal\Core\Plugin\DefaultPluginManager; /** * Provides the Data profile plugin manager. diff --git a/src/Plugin/ServiceDataTypeManager.php b/src/Plugin/ServiceDataTypeManager.php index a1c1950..d875944 100644 --- a/src/Plugin/ServiceDataTypeManager.php +++ b/src/Plugin/ServiceDataTypeManager.php @@ -2,9 +2,9 @@ namespace Drupal\dgi_actions\Plugin; -use Drupal\Core\Plugin\DefaultPluginManager; use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Extension\ModuleHandlerInterface; +use Drupal\Core\Plugin\DefaultPluginManager; /** * Provides the Service data type plugin manager. From 5d9a26e8e7caa063a006530a60a2162c41a6a487 Mon Sep 17 00:00:00 2001 From: JojoVes Date: Wed, 29 May 2024 16:59:38 -0300 Subject: [PATCH 5/7] final bit of cleanup for drush 12+ --- composer.json | 2 +- drush.services.yml => drush.10-11.services.yml | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename drush.services.yml => drush.10-11.services.yml (100%) diff --git a/composer.json b/composer.json index fd301df..3152660 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,7 @@ "extra": { "drush": { "services": { - "drush.services.yml": "^10" + "drush.10-11.services.yml": "^10 || ^11" } } } diff --git a/drush.services.yml b/drush.10-11.services.yml similarity index 100% rename from drush.services.yml rename to drush.10-11.services.yml From 4c79a60077b07adf8e647abfc204af9891ba3663 Mon Sep 17 00:00:00 2001 From: JojoVes Date: Wed, 29 May 2024 17:19:42 -0300 Subject: [PATCH 6/7] use correct ContainerInterface According to https://www.drush.org/12.x/dependency-injection/#create-method, the type should be `Psr\Container\ContainerInterface`, not `Symfony\Component\DependencyInjection\ContainerInterface`, which I almost didn't catch because both seem to work, but I'm making this change since it's specifically called out in the documentation. --- .../dgi_actions_handle/src/Drush/Commands/HandleCommands.php | 2 +- src/Drush/Commands/Generate.php | 2 +- src/Drush/Commands/PrintMissingEntityIds.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/dgi_actions_handle/src/Drush/Commands/HandleCommands.php b/modules/dgi_actions_handle/src/Drush/Commands/HandleCommands.php index 06cd67c..83fe70d 100644 --- a/modules/dgi_actions_handle/src/Drush/Commands/HandleCommands.php +++ b/modules/dgi_actions_handle/src/Drush/Commands/HandleCommands.php @@ -9,7 +9,7 @@ use Drupal\dgi_actions\Utility\IdentifierUtils; use Drush\Commands\DrushCommands; use GuzzleHttp\ClientInterface; -use Symfony\Component\DependencyInjection\ContainerInterface; +use Psr\Container\ContainerInterface; /** * Drush commands for Handle.net things. diff --git a/src/Drush/Commands/Generate.php b/src/Drush/Commands/Generate.php index 972e893..0ee242e 100644 --- a/src/Drush/Commands/Generate.php +++ b/src/Drush/Commands/Generate.php @@ -13,8 +13,8 @@ use Drupal\islandora\IslandoraUtils; use Drush\Commands\DrushCommands; use GuzzleHttp\ClientInterface; +use Psr\Container\ContainerInterface; use Psr\Log\LoggerInterface; -use Symfony\Component\DependencyInjection\ContainerInterface; /** * Drush commands for generating identifiers for existing objects. diff --git a/src/Drush/Commands/PrintMissingEntityIds.php b/src/Drush/Commands/PrintMissingEntityIds.php index 143c7b5..46dec55 100644 --- a/src/Drush/Commands/PrintMissingEntityIds.php +++ b/src/Drush/Commands/PrintMissingEntityIds.php @@ -8,7 +8,7 @@ use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\dgi_actions\Utility\IdentifierUtils; use Drush\Commands\DrushCommands; -use Symfony\Component\DependencyInjection\ContainerInterface; +use Psr\Container\ContainerInterface; /** * Drush commands for generating identifiers for existing objects. From 249e14da916263ab6b41cde589ce3e2db50289f2 Mon Sep 17 00:00:00 2001 From: JojoVes Date: Thu, 30 May 2024 14:42:14 -0300 Subject: [PATCH 7/7] missed this namespace update --- modules/dgi_actions_handle/src/Drush/Commands/Update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/dgi_actions_handle/src/Drush/Commands/Update.php b/modules/dgi_actions_handle/src/Drush/Commands/Update.php index ed93681..2abaf47 100644 --- a/modules/dgi_actions_handle/src/Drush/Commands/Update.php +++ b/modules/dgi_actions_handle/src/Drush/Commands/Update.php @@ -1,6 +1,6 @@