Use user service to manage user on admin command.
This commit is contained in:
parent
063bec407d
commit
74ed1b14e1
|
@ -25,18 +25,18 @@ use Symfony\Component\Console\Output\OutputInterface;
|
||||||
class CreateAdminCommand extends Command
|
class CreateAdminCommand extends Command
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var UserStore
|
* @var UserService
|
||||||
*/
|
*/
|
||||||
protected $userStore;
|
protected $userService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param UserStore $userStore
|
* @param UserService $userService
|
||||||
*/
|
*/
|
||||||
public function __construct(UserStore $userStore)
|
public function __construct(UserService $userService)
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
|
||||||
$this->userStore = $userStore;
|
$this->userService = $userService;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function configure()
|
protected function configure()
|
||||||
|
@ -53,8 +53,6 @@ class CreateAdminCommand extends Command
|
||||||
*/
|
*/
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
$userService = new UserService($this->userStore);
|
|
||||||
|
|
||||||
/** @var $dialog \Symfony\Component\Console\Helper\DialogHelper */
|
/** @var $dialog \Symfony\Component\Console\Helper\DialogHelper */
|
||||||
$dialog = $this->getHelperSet()->get('dialog');
|
$dialog = $this->getHelperSet()->get('dialog');
|
||||||
|
|
||||||
|
@ -72,7 +70,7 @@ class CreateAdminCommand extends Command
|
||||||
$adminPass = $dialog->askHiddenResponse($output, Lang::get('enter_password'));
|
$adminPass = $dialog->askHiddenResponse($output, Lang::get('enter_password'));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$userService->createUser($adminName, $adminEmail, $adminPass, true);
|
$this->userService->createUser($adminName, $adminEmail, $adminPass, true);
|
||||||
$output->writeln(Lang::get('user_created'));
|
$output->writeln(Lang::get('user_created'));
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$output->writeln(sprintf('<error>%s</error>', Lang::get('failed_to_create')));
|
$output->writeln(sprintf('<error>%s</error>', Lang::get('failed_to_create')));
|
||||||
|
|
|
@ -37,9 +37,12 @@ services:
|
||||||
application:
|
application:
|
||||||
class: PHPCI\Application
|
class: PHPCI\Application
|
||||||
arguments: [@config, @http.request, @http.response, @storage.user, @storage.project]
|
arguments: [@config, @http.request, @http.response, @storage.user, @storage.project]
|
||||||
build:
|
service.build:
|
||||||
class: PHPCI\Service\BuildService
|
class: PHPCI\Service\BuildService
|
||||||
arguments: [@storage.build]
|
arguments: [@storage.build]
|
||||||
|
service.user:
|
||||||
|
class: PHPCI\Service\UserService
|
||||||
|
arguments: [@storage.user]
|
||||||
|
|
||||||
console.application:
|
console.application:
|
||||||
class: Symfony\Component\Console\Application
|
class: Symfony\Component\Console\Application
|
||||||
|
@ -83,12 +86,12 @@ services:
|
||||||
console.command.create_admin:
|
console.command.create_admin:
|
||||||
class: PHPCI\Command\CreateAdminCommand
|
class: PHPCI\Command\CreateAdminCommand
|
||||||
arguments:
|
arguments:
|
||||||
- @storage.user
|
- @service.user
|
||||||
console.command.create_build:
|
console.command.create_build:
|
||||||
class: PHPCI\Command\CreateBuildCommand
|
class: PHPCI\Command\CreateBuildCommand
|
||||||
arguments:
|
arguments:
|
||||||
- @storage.project
|
- @storage.project
|
||||||
- @build
|
- @service.build
|
||||||
console.command.install:
|
console.command.install:
|
||||||
class: PHPCI\Command\InstallCommand
|
class: PHPCI\Command\InstallCommand
|
||||||
console.command.generate:
|
console.command.generate:
|
||||||
|
|
Loading…
Reference in a new issue