Skip to content
Snippets Groups Projects
Commit e8bda9de authored by Ide Braakman's avatar Ide Braakman Committed by Bojan Bogdanovic
Browse files

Resolve #3454338 "Support drush 12"

parent b0dcf6c4
No related branches found
No related tags found
1 merge request!147Resolve #3454338 "Support drush 12"
Pipeline #327949 passed with warnings
......@@ -17,12 +17,5 @@
"name": "Mateu Aguiló Bosch",
"email": "mateu.aguilo.bosch@gmail.com"
}
],
"extra": {
"drush": {
"services": {
"drush.services.yml": "^9 || ^10 || ^11"
}
}
}
]
}
services:
simple_oauth_commands:
class: Drupal\simple_oauth\Drush\Commands\SimpleOauthCommands
arguments: ['@simple_oauth.key.generator', '@file_system']
tags:
- { name: drush.command }
......@@ -2,59 +2,35 @@
namespace Drupal\simple_oauth\Drush\Commands;
use Drupal\Component\DependencyInjection\ContainerInterface;
use Drupal\simple_oauth\Service\Exception\ExtensionNotLoadedException;
use Drupal\simple_oauth\Service\Exception\FilesystemValidationException;
use Drupal\simple_oauth\Service\KeyGeneratorService;
use Drush\Attributes as CLI;
use Drush\Commands\AutowireTrait;
use Drush\Commands\DrushCommands;
use Symfony\Component\DependencyInjection\Attribute\Autowire;
/**
* Drush commands for Simple OAuth.
*/
class SimpleOauthCommands extends DrushCommands {
/**
* The key generator.
*
* @var \Drupal\simple_oauth\Service\KeyGeneratorService
*/
private KeyGeneratorService $keygen;
use AutowireTrait;
/**
* SimpleOauthCommands constructor.
*
* @param \Drupal\simple_oauth\Service\KeyGeneratorService $keygen
* The key generator service.
*/
public function __construct(KeyGeneratorService $keygen) {
public function __construct(
#[Autowire(service: 'simple_oauth.key.generator')] protected KeyGeneratorService $keygen,
) {
parent::__construct();
$this->keygen = $keygen;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container): self {
return new static(
$container->get('simple_oauth.key.generator')
);
}
/**
* Generate Oauth2 Keys.
*
* @param string $keypath
* The full path or a file stream were the key files will be saved.
*
* @usage simple-oauth:generate-keys /var/www/drupal-example.org/keys
* Creates the keys in the /var/www/drupal-example.org/keys directory.
*
* @command simple-oauth:generate-keys
* @aliases so:generate-keys, sogk
*
* @validate-module-enabled simple_oauth
*/
public function generateKeys(string $keypath) {
#[CLI\Argument(name: 'keypath', description: 'The full path or a file stream where the key files will be saved.')]
#[CLI\Command(name: 'simple-oauth:generate-keys', aliases: ['so:generate-keys', 'sogk'])]
#[CLI\Usage(name: 'simple-oauth:generate-keys /var/www/drupal-example.org/keys', description: 'Creates the keys in the /var/www/drupal-example.org/keys directory.')]
public function generateKeys(string $keypath): void {
try {
$this->keygen->generateKeys($keypath);
$this->logger()->notice(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment