entityTypeManager = $entityTypeManager; parent::__construct(); } /** * {@inheritdoc} */ protected function configure() { $this ->setName('user:login:url') ->setDescription($this->trans('commands.user.login.url.description')) ->addArgument( 'user-id', InputArgument::REQUIRED, $this->trans('commands.user.login.url.options.user-id'), null ); } /** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $io = new DrupalStyle($input, $output); $uid = $input->getArgument('user-id'); $user = $this->entityTypeManager->getStorage('user')->load($uid); if (!$user) { $io->error( sprintf( $this->trans('commands.user.login.url.errors.invalid-user'), $uid ) ); return 1; } $url = user_pass_reset_url($user); $io->success( sprintf( $this->trans('commands.user.login.url.messages.url'), $user->getUsername(), $url ) ); } }