Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DGI9-477: Fix/drush 12 #23

Merged
merged 9 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"extra": {
"drush": {
"services": {
"drush.services.yml": "^10"
"drush.10.services.yml": "^10 || ^11"
}
}
}
Expand Down
68 changes: 68 additions & 0 deletions drush.10.services.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
---
services:
islandora_drush_utils.deleter:
class: \Drupal\islandora_drush_utils\Drush\Commands\Deleter
arguments:
- '@entity_type.manager'
- '@queue'
- '@database'
- '@entity_field.manager'
tags:
- name: drush.command
islandora_drush_utils.rederiver:
class: \Drupal\islandora_drush_utils\Drush\Commands\Rederive
arguments:
- '@islandora.utils'
- '@entity_type.manager'
tags:
- name: drush.command
islandora_drush_utils.rederive_thumbnails:
class: \Drupal\islandora_drush_utils\Drush\Commands\GenerateThumbnails
arguments:
- '@entity_type.manager'
- '@database'
tags:
- name: drush.command
islandora_drush_utils.command.user_wrapper:
class: \Drupal\islandora_drush_utils\Drush\Commands\UserWrapperCommands
arguments:
- '@account_switcher'
- '@entity_type.manager'
tags:
- name: drush.command
islandora_drush_utils.command.user_wrapping_alterer:
class: \Drupal\islandora_drush_utils\Drush\CommandInfoAlterers\UserWrappingAlterer
tags:
- name: drush.command_info_alterer
arguments:
- '@logger.islandora_drush_utils'
- false
islandora_drush_utils.null_child_weight_updater:
class: \Drupal\islandora_drush_utils\Drush\Commands\NullChildWeight
arguments:
- '@entity_type.manager'
- '@database'
- '@islandora.utils'
tags:
- name: drush.command
islandora_drush_utils.missing_derivatives:
class: \Drupal\islandora_drush_utils\Drush\Commands\MissingDerivatives
arguments:
- '@entity_type.manager'
- '@dgi_standard_derivative_examiner.examiner'
tags:
- name: drush.command
islandora_drush_utils.derivatives_generator:
class: \Drupal\islandora_drush_utils\Drush\Commands\DerivativesGenerator
arguments:
- '@entity_type.manager'
tags:
- name: drush.command
islandora_drush_utils.bulk_publish_unpublish:
class: \Drupal\islandora_drush_utils\Drush\Commands\PublishUnpublishCollections
arguments:
- '@entity_type.manager'
- '@islandora.utils'
- '@logger.islandora_drush_utils'
tags:
- { name: drush.command }
59 changes: 0 additions & 59 deletions drush.services.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Drupal\islandora_drush_utils\Commands;
namespace Drupal\islandora_drush_utils\Drush\CommandInfoAlterers;

use Consolidation\AnnotatedCommand\CommandInfoAltererInterface;
use Consolidation\AnnotatedCommand\Parser\CommandInfo;
Expand Down Expand Up @@ -29,32 +29,20 @@ class UserWrappingAlterer implements CommandInfoAltererInterface {
'migrate:rollback',
];

/**
* The logger to use.
*
* @var \Psr\Log\LoggerInterface
*/
protected $logger;

/**
* Whether we should emit debug messages.
*
* @var bool
*/
protected $debug;

/**
* Constructor.
*/
public function __construct(LoggerInterface $logger, $debug = FALSE) {
$this->logger = $logger;
$this->debug = $debug;
public function __construct(
protected LoggerInterface $logger,
protected $debug = FALSE,
) {
// No-op.
}

/**
* {@inheritdoc}
*/
public function alterCommandInfo(CommandInfo $commandInfo, $commandFileInstance) {
public function alterCommandInfo(CommandInfo $commandInfo, $commandFileInstance) : void {
if (!$commandInfo->hasAnnotation(static::ANNO) && in_array($commandInfo->getName(), static::COMMANDS)) {
if ($this->debug) {
$this->logger->debug(
Expand Down
45 changes: 7 additions & 38 deletions src/Commands/Deleter.php → src/Drush/Commands/Deleter.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Drupal\islandora_drush_utils\Commands;
namespace Drupal\islandora_drush_utils\Drush\Commands;

use Drupal\Component\Utility\Random;
use Drupal\Core\Database\Connection;
Expand All @@ -12,6 +12,7 @@
use Drupal\Core\Queue\QueueFactory;
use Drupal\Core\Queue\QueueInterface;
use Drupal\Core\TypedData\TranslatableInterface;
use Drupal\islandora_drush_utils\Drush\Commands\Traits\LoggingTrait;
use Drupal\media\MediaInterface;
use Drupal\node\NodeInterface;
use Drush\Commands\DrushCommands;
Expand All @@ -29,34 +30,6 @@ class Deleter extends DrushCommands implements ContainerInjectionInterface {

use LoggingTrait;

/**
* The database connection service.
*
* @var \Drupal\Core\Database\Connection
*/
protected Connection $database;

/**
* The entity type manager service.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected EntityTypeManagerInterface $entityTypeManager;

/**
* The entity field manager service.
*
* @var \Drupal\Core\Entity\EntityFieldManagerInterface
*/
protected EntityFieldManagerInterface $entityFieldManager;

/**
* The queue factory service.
*
* @var \Drupal\Core\Queue\QueueFactory
*/
protected QueueFactory $queueFactory;

/**
* The node storage service.
*
Expand Down Expand Up @@ -103,16 +76,12 @@ class Deleter extends DrushCommands implements ContainerInjectionInterface {
* Constructor.
*/
public function __construct(
EntityTypeManagerInterface $entity_type_manager,
QueueFactory $queue_factory,
Connection $database,
EntityFieldManagerInterface $entity_field_manager
protected EntityTypeManagerInterface $entityTypeManager,
protected QueueFactory $queueFactory,
protected Connection $database,
protected EntityFieldManagerInterface $entityFieldManager
) {
parent::__construct();
$this->entityTypeManager = $entity_type_manager;
$this->entityFieldManager = $entity_field_manager;
$this->queueFactory = $queue_factory;
$this->database = $database;

$this->queuePrefix = implode(
'.', [
Expand All @@ -127,7 +96,7 @@ public function __construct(
/**
* {@inheritDoc}
*/
public static function create(ContainerInterface $container) {
public static function create(ContainerInterface $container) : self {
return new static(
$container->get('entity_type.manager'),
$container->get('queue'),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<?php

namespace Drupal\islandora_drush_utils\Commands;
namespace Drupal\islandora_drush_utils\Drush\Commands;

use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\Core\DependencyInjection\DependencySerializationTrait;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\islandora_drush_utils\Drush\Commands\Traits\NodeIdParsingTrait;
use Drupal\islandora_drush_utils\Services\DerivativesGeneratorBatchService;
use Drush\Commands\DrushCommands;
use Symfony\Component\DependencyInjection\ContainerInterface;
Expand All @@ -19,22 +20,13 @@ class DerivativesGenerator extends DrushCommands implements ContainerInjectionIn
use StringTranslationTrait;
use NodeIdParsingTrait;

/**
* Entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;

/**
* Constructor.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager service.
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager) {
public function __construct(
protected EntityTypeManagerInterface $entityTypeManager,
) {
parent::__construct();
$this->entityTypeManager = $entity_type_manager;
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<?php

namespace Drupal\islandora_drush_utils\Commands;
namespace Drupal\islandora_drush_utils\Drush\Commands;

use Drupal\Core\Database\Connection;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\islandora_drush_utils\Drush\Commands\Traits\NodeIdParsingTrait;
use Drupal\islandora_drush_utils\Services\DerivativesGeneratorBatchService;
use Drush\Commands\DrushCommands;
use Symfony\Component\DependencyInjection\ContainerInterface;
Expand All @@ -18,32 +19,19 @@ class GenerateThumbnails extends DrushCommands implements ContainerInjectionInte
use StringTranslationTrait;
use NodeIdParsingTrait;

/**
* Entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $storage;

/**
* Database connection.
*
* @var \Drupal\Core\Database\Connection
*/
protected $database;

/**
* Constructor.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $storage
* The entity type manager service.
* @param \Drupal\Core\Database\Connection $database
* A Drupal database connection.
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager, Connection $database) {
public function __construct(
protected EntityTypeManagerInterface $storage,
protected Connection $database,
) {
parent::__construct();
$this->storage = $entity_type_manager;
$this->database = $database;
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<?php

namespace Drupal\islandora_drush_utils\Commands;
namespace Drupal\islandora_drush_utils\Drush\Commands;

use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\Core\DependencyInjection\DependencySerializationTrait;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Entity\Query\QueryInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\dgi_standard_derivative_examiner\Utility\ExaminerInterface;
use Drupal\islandora_drush_utils\Drush\Commands\Traits\LoggingTrait;
use Drupal\node\NodeStorageInterface;
use Drush\Commands\DrushCommands;
use Psr\Log\LogLevel;
Expand Down
Loading
Loading