Receive \OC\User\Manager as a constructor dependency.
This commit is contained in:
parent
f216d81408
commit
52e7bf9630
|
@ -14,6 +14,15 @@ use Symfony\Component\Console\Input\InputArgument;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
|
||||||
class ResetPassword extends Command {
|
class ResetPassword extends Command {
|
||||||
|
|
||||||
|
/** @var \OC\User\Manager */
|
||||||
|
protected $userManager;
|
||||||
|
|
||||||
|
public function __construct(\OC\User\Manager $userManager) {
|
||||||
|
$this->userManager = $userManager;
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
protected function configure() {
|
protected function configure() {
|
||||||
$this
|
$this
|
||||||
->setName('resetpassword')
|
->setName('resetpassword')
|
||||||
|
@ -29,8 +38,7 @@ class ResetPassword extends Command {
|
||||||
protected function execute(InputInterface $input, OutputInterface $output) {
|
protected function execute(InputInterface $input, OutputInterface $output) {
|
||||||
$username = $input->getArgument('user');
|
$username = $input->getArgument('user');
|
||||||
|
|
||||||
$userManager = \OC::$server->getUserManager();
|
$user = $this->userManager->get($username);
|
||||||
$user = $userManager->get($username);
|
|
||||||
if (is_null($user)) {
|
if (is_null($user)) {
|
||||||
$output->writeln("<error>There is no user called " . $username . "</error>");
|
$output->writeln("<error>There is no user called " . $username . "</error>");
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
$application->add(new OC\Core\Command\Status);
|
$application->add(new OC\Core\Command\Status);
|
||||||
$application->add(new OC\Core\Command\Db\GenerateChangeScript());
|
$application->add(new OC\Core\Command\Db\GenerateChangeScript());
|
||||||
$application->add(new OC\Core\Command\Upgrade());
|
$application->add(new OC\Core\Command\Upgrade());
|
||||||
$application->add(new OC\Core\Command\ResetPassword());
|
$application->add(new OC\Core\Command\ResetPassword(\OC::$server->getUserManager()));
|
||||||
$application->add(new OC\Core\Command\Maintenance\SingleUser());
|
$application->add(new OC\Core\Command\Maintenance\SingleUser());
|
||||||
$application->add(new OC\Core\Command\App\Disable());
|
$application->add(new OC\Core\Command\App\Disable());
|
||||||
$application->add(new OC\Core\Command\App\Enable());
|
$application->add(new OC\Core\Command\App\Enable());
|
||||||
|
|
Loading…
Reference in New Issue