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