@@ -13,64 +13,64 @@ |
||
| 13 | 13 | |
| 14 | 14 | class ImportModuleCommand extends Command |
| 15 | 15 | { |
| 16 | - private $em; |
|
| 16 | + private $em; |
|
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * ImportModuleCommand constructor. |
|
| 20 | - * @param EntityManagerInterface $em |
|
| 21 | - * @param string|null $name |
|
| 22 | - */ |
|
| 23 | - public function __construct(EntityManagerInterface $em, string $name = null) |
|
| 24 | - { |
|
| 25 | - parent::__construct($name); |
|
| 26 | - $this->em = $em; |
|
| 27 | - } |
|
| 18 | + /** |
|
| 19 | + * ImportModuleCommand constructor. |
|
| 20 | + * @param EntityManagerInterface $em |
|
| 21 | + * @param string|null $name |
|
| 22 | + */ |
|
| 23 | + public function __construct(EntityManagerInterface $em, string $name = null) |
|
| 24 | + { |
|
| 25 | + parent::__construct($name); |
|
| 26 | + $this->em = $em; |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - protected function configure() |
|
| 30 | - { |
|
| 31 | - $this |
|
| 32 | - ->setName('ribsadmin:import-module') |
|
| 33 | - ->setDescription('Import a module in ribs admin') |
|
| 34 | - ->addArgument( |
|
| 35 | - 'package-name', |
|
| 36 | - InputArgument::REQUIRED, |
|
| 37 | - 'Name of composer package to import' |
|
| 38 | - ) |
|
| 39 | - ->addArgument( |
|
| 40 | - 'module-name', |
|
| 41 | - InputArgument::REQUIRED, |
|
| 42 | - 'Name of package to display in app' |
|
| 43 | - ) |
|
| 44 | - ; |
|
| 45 | - } |
|
| 29 | + protected function configure() |
|
| 30 | + { |
|
| 31 | + $this |
|
| 32 | + ->setName('ribsadmin:import-module') |
|
| 33 | + ->setDescription('Import a module in ribs admin') |
|
| 34 | + ->addArgument( |
|
| 35 | + 'package-name', |
|
| 36 | + InputArgument::REQUIRED, |
|
| 37 | + 'Name of composer package to import' |
|
| 38 | + ) |
|
| 39 | + ->addArgument( |
|
| 40 | + 'module-name', |
|
| 41 | + InputArgument::REQUIRED, |
|
| 42 | + 'Name of package to display in app' |
|
| 43 | + ) |
|
| 44 | + ; |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - protected function execute(InputInterface $input, OutputInterface $output) |
|
| 48 | - { |
|
| 49 | - $pacakge_name = $input->getArgument('package-name'); |
|
| 50 | - $output->writeln("Start composer require " . $pacakge_name); |
|
| 47 | + protected function execute(InputInterface $input, OutputInterface $output) |
|
| 48 | + { |
|
| 49 | + $pacakge_name = $input->getArgument('package-name'); |
|
| 50 | + $output->writeln("Start composer require " . $pacakge_name); |
|
| 51 | 51 | |
| 52 | - $process = new Process("composer require " . $pacakge_name); |
|
| 53 | - $process->run(function ($type, $buffer) { |
|
| 54 | - echo $buffer; |
|
| 55 | - }); |
|
| 52 | + $process = new Process("composer require " . $pacakge_name); |
|
| 53 | + $process->run(function ($type, $buffer) { |
|
| 54 | + echo $buffer; |
|
| 55 | + }); |
|
| 56 | 56 | |
| 57 | - if (!$process->isSuccessful()) { |
|
| 58 | - throw new ProcessFailedException($process); |
|
| 59 | - } |
|
| 57 | + if (!$process->isSuccessful()) { |
|
| 58 | + throw new ProcessFailedException($process); |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - $output->writeln("End composer require " . $pacakge_name); |
|
| 62 | - $output->writeln("Start insertion of module in database " . $pacakge_name); |
|
| 61 | + $output->writeln("End composer require " . $pacakge_name); |
|
| 62 | + $output->writeln("Start insertion of module in database " . $pacakge_name); |
|
| 63 | 63 | |
| 64 | - $module = new Module(); |
|
| 65 | - $module->setPackageName($pacakge_name); |
|
| 66 | - $module->setTitle($input->getArgument('module-name')); |
|
| 67 | - $module->setActive(false); |
|
| 68 | - $module->setDisplayed(true); |
|
| 69 | - $this->em->persist($module); |
|
| 70 | - $this->em->flush(); |
|
| 64 | + $module = new Module(); |
|
| 65 | + $module->setPackageName($pacakge_name); |
|
| 66 | + $module->setTitle($input->getArgument('module-name')); |
|
| 67 | + $module->setActive(false); |
|
| 68 | + $module->setDisplayed(true); |
|
| 69 | + $this->em->persist($module); |
|
| 70 | + $this->em->flush(); |
|
| 71 | 71 | |
| 72 | - $output->writeln("Installation of " . $pacakge_name . " is finished. You have now to configure this module in your administration interface"); |
|
| 72 | + $output->writeln("Installation of " . $pacakge_name . " is finished. You have now to configure this module in your administration interface"); |
|
| 73 | 73 | |
| 74 | - return 0; |
|
| 75 | - } |
|
| 74 | + return 0; |
|
| 75 | + } |
|
| 76 | 76 | } |
@@ -13,80 +13,80 @@ |
||
| 13 | 13 | |
| 14 | 14 | class CreateAdminCommand extends Command |
| 15 | 15 | { |
| 16 | - /** @var EntityManagerInterface */ |
|
| 17 | - private $em; |
|
| 16 | + /** @var EntityManagerInterface */ |
|
| 17 | + private $em; |
|
| 18 | 18 | |
| 19 | - /** @var UserPasswordEncoderInterface */ |
|
| 20 | - private $passwordEncoder; |
|
| 19 | + /** @var UserPasswordEncoderInterface */ |
|
| 20 | + private $passwordEncoder; |
|
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * CreateAdminCommand constructor. |
|
| 24 | - * @param EntityManagerInterface $em |
|
| 25 | - * @param UserPasswordEncoderInterface $passwordEncoder |
|
| 26 | - * @param string|null $name |
|
| 27 | - */ |
|
| 28 | - public function __construct(EntityManagerInterface $em, UserPasswordEncoderInterface $passwordEncoder, string $name = null) |
|
| 29 | - { |
|
| 30 | - parent::__construct($name); |
|
| 31 | - $this->em = $em; |
|
| 32 | - $this->passwordEncoder = $passwordEncoder; |
|
| 33 | - } |
|
| 22 | + /** |
|
| 23 | + * CreateAdminCommand constructor. |
|
| 24 | + * @param EntityManagerInterface $em |
|
| 25 | + * @param UserPasswordEncoderInterface $passwordEncoder |
|
| 26 | + * @param string|null $name |
|
| 27 | + */ |
|
| 28 | + public function __construct(EntityManagerInterface $em, UserPasswordEncoderInterface $passwordEncoder, string $name = null) |
|
| 29 | + { |
|
| 30 | + parent::__construct($name); |
|
| 31 | + $this->em = $em; |
|
| 32 | + $this->passwordEncoder = $passwordEncoder; |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - protected function configure() |
|
| 36 | - { |
|
| 37 | - $this |
|
| 38 | - ->setName('ribsadmin:create-admin') |
|
| 39 | - ->setDescription('Create an admin in ribs admin') |
|
| 40 | - ->addArgument( |
|
| 41 | - 'firstname', |
|
| 42 | - InputArgument::REQUIRED, |
|
| 43 | - 'Firstname of admin to create' |
|
| 44 | - ) |
|
| 45 | - ->addArgument( |
|
| 46 | - 'lastname', |
|
| 47 | - InputArgument::REQUIRED, |
|
| 48 | - 'Lastname of admin to create' |
|
| 49 | - ) |
|
| 50 | - ->addArgument( |
|
| 51 | - 'email', |
|
| 52 | - InputArgument::REQUIRED, |
|
| 53 | - 'email of admin to create' |
|
| 54 | - ) |
|
| 55 | - ->addArgument( |
|
| 56 | - 'password', |
|
| 57 | - InputArgument::REQUIRED, |
|
| 58 | - 'password of admin to create' |
|
| 59 | - ) |
|
| 60 | - ; |
|
| 61 | - } |
|
| 35 | + protected function configure() |
|
| 36 | + { |
|
| 37 | + $this |
|
| 38 | + ->setName('ribsadmin:create-admin') |
|
| 39 | + ->setDescription('Create an admin in ribs admin') |
|
| 40 | + ->addArgument( |
|
| 41 | + 'firstname', |
|
| 42 | + InputArgument::REQUIRED, |
|
| 43 | + 'Firstname of admin to create' |
|
| 44 | + ) |
|
| 45 | + ->addArgument( |
|
| 46 | + 'lastname', |
|
| 47 | + InputArgument::REQUIRED, |
|
| 48 | + 'Lastname of admin to create' |
|
| 49 | + ) |
|
| 50 | + ->addArgument( |
|
| 51 | + 'email', |
|
| 52 | + InputArgument::REQUIRED, |
|
| 53 | + 'email of admin to create' |
|
| 54 | + ) |
|
| 55 | + ->addArgument( |
|
| 56 | + 'password', |
|
| 57 | + InputArgument::REQUIRED, |
|
| 58 | + 'password of admin to create' |
|
| 59 | + ) |
|
| 60 | + ; |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - protected function execute(InputInterface $input, OutputInterface $output) |
|
| 64 | - { |
|
| 65 | - $firstname = $input->getArgument('firstname'); |
|
| 66 | - $lastname = $input->getArgument('lastname'); |
|
| 67 | - $email = $input->getArgument('email'); |
|
| 68 | - $password = $input->getArgument('password'); |
|
| 63 | + protected function execute(InputInterface $input, OutputInterface $output) |
|
| 64 | + { |
|
| 65 | + $firstname = $input->getArgument('firstname'); |
|
| 66 | + $lastname = $input->getArgument('lastname'); |
|
| 67 | + $email = $input->getArgument('email'); |
|
| 68 | + $password = $input->getArgument('password'); |
|
| 69 | 69 | |
| 70 | - $output->writeln("Create admin " . $firstname . " " . $lastname); |
|
| 70 | + $output->writeln("Create admin " . $firstname . " " . $lastname); |
|
| 71 | 71 | |
| 72 | - $user = new User(); |
|
| 73 | - $user->setFirstname($firstname); |
|
| 74 | - $user->setLastname($lastname); |
|
| 75 | - $user->setAccessRights("*"); |
|
| 76 | - $this->em->persist($user); |
|
| 72 | + $user = new User(); |
|
| 73 | + $user->setFirstname($firstname); |
|
| 74 | + $user->setLastname($lastname); |
|
| 75 | + $user->setAccessRights("*"); |
|
| 76 | + $this->em->persist($user); |
|
| 77 | 77 | |
| 78 | - $account = new Account(); |
|
| 79 | - $temp_password = $this->passwordEncoder->encodePassword($account, $password); |
|
| 80 | - $account->setPassword($temp_password); |
|
| 81 | - $account->setUser($user); |
|
| 82 | - $account->setEmail($email); |
|
| 83 | - $account->setUsername(substr($firstname, 0, 1).".".$lastname); |
|
| 84 | - $this->em->persist($account); |
|
| 78 | + $account = new Account(); |
|
| 79 | + $temp_password = $this->passwordEncoder->encodePassword($account, $password); |
|
| 80 | + $account->setPassword($temp_password); |
|
| 81 | + $account->setUser($user); |
|
| 82 | + $account->setEmail($email); |
|
| 83 | + $account->setUsername(substr($firstname, 0, 1).".".$lastname); |
|
| 84 | + $this->em->persist($account); |
|
| 85 | 85 | |
| 86 | - $this->em->flush(); |
|
| 86 | + $this->em->flush(); |
|
| 87 | 87 | |
| 88 | - $output->writeln("End Create admin " . $firstname . " " . $lastname); |
|
| 88 | + $output->writeln("End Create admin " . $firstname . " " . $lastname); |
|
| 89 | 89 | |
| 90 | - return 0; |
|
| 91 | - } |
|
| 90 | + return 0; |
|
| 91 | + } |
|
| 92 | 92 | } |