1 | <?php |
||
31 | final class BootstrapIdentityCommand extends AbstractBootstrapCommand |
||
32 | { |
||
33 | protected function configure() |
||
34 | { |
||
35 | $this |
||
36 | ->setDescription('Creates an identity') |
||
37 | ->addArgument('name-id', InputArgument::REQUIRED, 'The NameID of the identity to create') |
||
38 | ->addArgument('institution', InputArgument::REQUIRED, 'The institution of the identity to create') |
||
39 | ->addArgument('common-name', InputArgument::REQUIRED, 'The Common Name of the identity to create') |
||
40 | ->addArgument('email', InputArgument::REQUIRED, 'The e-mail address of the identity to create') |
||
41 | ->addArgument('preferred-locale', InputArgument::REQUIRED, 'The preferred locale of the identity to create') |
||
42 | ->addArgument('actor-id', InputArgument::REQUIRED, 'The id of the vetting actor'); |
||
43 | } |
||
44 | |||
45 | protected function execute(InputInterface $input, OutputInterface $output) |
||
46 | { |
||
47 | $this->tokenStorage->setToken( |
||
48 | new AnonymousToken('cli.bootstrap-identity-with-sms-token', 'cli', ['ROLE_SS']) |
||
|
|||
49 | ); |
||
50 | |||
51 | $nameId = new NameId($input->getArgument('name-id')); |
||
52 | $institutionText = $input->getArgument('institution'); |
||
53 | $institution = new Institution($institutionText); |
||
54 | $commonName = $input->getArgument('common-name'); |
||
55 | $email = $input->getArgument('email'); |
||
56 | $preferredLocale = $input->getArgument('preferred-locale'); |
||
57 | $actorId = $input->getArgument('actor-id'); |
||
58 | |||
59 | $this->enrichEventMetadata($actorId); |
||
60 | |||
61 | $output->writeln(sprintf('<comment>Adding an identity named: %s</comment>', $commonName)); |
||
62 | if ($this->tokenBootstrapService->hasIdentityWithNameIdAndInstitution($nameId, $institution)) { |
||
63 | $output->writeln( |
||
64 | sprintf( |
||
65 | '<error>An identity with name ID "%s" from institution "%s" already exists</error>', |
||
66 | $nameId->getNameId(), |
||
67 | $institution->getInstitution() |
||
68 | ) |
||
69 | ); |
||
70 | return; |
||
71 | } |
||
72 | try { |
||
73 | $this->beginTransaction(); |
||
74 | $output->writeln('<info>Creating a new identity</info>'); |
||
75 | $identity = $this->createIdentity($institution, $nameId, $commonName, $email, $preferredLocale); |
||
76 | $this->finishTransaction(); |
||
77 | } catch (Exception $e) { |
||
78 | $output->writeln( |
||
79 | sprintf( |
||
80 | '<error>An Error occurred when trying to bootstrap the identity: "%s"</error>', |
||
81 | $e->getMessage() |
||
82 | ) |
||
83 | ); |
||
84 | $this->rollback(); |
||
85 | throw $e; |
||
86 | } |
||
87 | $output->writeln( |
||
88 | sprintf('<info>Successfully created identity with UUID %s</info>', $identity->id) |
||
89 | ); |
||
90 | } |
||
91 | |||
92 | protected function createIdentity( |
||
111 | } |
||
112 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: