Skip to content

Commit

Permalink
Honor Bootstrap in LoginCommands by using createEarly() (#5753)
Browse files Browse the repository at this point in the history
Also remove stray Bootstrap Attribute in pm:install
  • Loading branch information
weitzman authored Sep 8, 2023
1 parent 7b024fa commit b924aa6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
10 changes: 4 additions & 6 deletions src/Commands/core/LoginCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,14 @@ final class LoginCommands extends DrushCommands implements SiteAliasManagerAware

const LOGIN = 'user:login';

public function __construct(protected TimeInterface $time, protected LanguageManagerInterface $languageManager, private BootstrapManager $bootstrapManager)
public function __construct(private BootstrapManager $bootstrapManager)
{
parent::__construct();
}

public static function create(ContainerInterface $container, $drush_container): self
public static function createEarly($drush_container): self
{
$commandHandler = new static(
$container->get('datetime.time'),
$container->get('language_manager'),
$drush_container->get('bootstrap.manager')
);

Expand Down Expand Up @@ -95,7 +93,7 @@ public function login(string $path = '', $options = ['name' => null, 'uid' => nu
throw new \InvalidArgumentException(dt('Account !name is blocked and thus cannot login. The user:unblock command may be helpful.', ['!name' => $account->getAccountName()]));
}

$timestamp = $this->time->getRequestTime();
$timestamp = \Drupal::time()->getRequestTime();
$link = Url::fromRoute(
'user.reset.login',
[
Expand All @@ -106,7 +104,7 @@ public function login(string $path = '', $options = ['name' => null, 'uid' => nu
[
'absolute' => true,
'query' => $path ? ['destination' => $path] : [],
'language' => $this->languageManager->getLanguage($account->getPreferredLangcode()),
'language' => \Drupal::languageManager()->getLanguage($account->getPreferredLangcode()),
]
)->toString();
}
Expand Down
1 change: 0 additions & 1 deletion src/Commands/pm/PmCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ public function getExtensionListModule(): ModuleExtensionList
#[CLI\Command(name: self::INSTALL, aliases: ['in', 'install', 'pm-install', 'en', 'pm-enable', 'pm:enable'])]
#[CLI\Argument(name: 'modules', description: 'A comma delimited list of modules.')]
#[CLI\Usage(name: 'drush pm:install --simulate content_moderation', description: "Display what modules would be installed but don't install them.")]
#[CLI\Bootstrap(level: DrupalBootLevels::ROOT)]
public function install(array $modules): void
{
$modules = StringUtils::csvToArray($modules);
Expand Down

0 comments on commit b924aa6

Please sign in to comment.