示例#1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     for ($i = 0; $i < 50; ++$i) {
         $userId = UserFixturesCommand::USER_IDS[array_rand(UserFixturesCommand::USER_IDS)];
         $this->queryBus->handle(new FilterOrganizationsQuery($userId, 0, 1), $organizations);
         if (empty($organizations)) {
             continue;
         }
         $this->commandBus->handle(new CreateProjectCommand('Project ' . $i, $organizations[0]['id'], $organizations[0]['owners'][0]['user_id'], Uuid::generate()));
     }
     $output->writeln('Project population is successfully done');
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     for ($i = 0; $i < 10; ++$i) {
         $userId = UserFixturesCommand::USER_IDS[array_rand(UserFixturesCommand::USER_IDS)];
         $command = new CreateOrganizationCommand($userId, 'Organization ' . $i, Uuid::generate());
         $this->commandBus->handle($command);
         try {
             $iterations = mt_rand(0, 2);
             for ($j = 0; $j < $iterations; ++$j) {
                 $this->commandBus->handle(new AddOrganizationMemberToOrganizationCommand(UserFixturesCommand::USER_IDS[array_rand(UserFixturesCommand::USER_IDS)], $command->id(), $userId));
             }
         } catch (OrganizationMemberIsAlreadyAnOwnerException $exception) {
             $output->writeln($exception->getMessage());
         } catch (CollectionElementAlreadyAddedException $exception) {
             $output->writeln($exception->getMessage());
         }
     }
     $output->writeln('Organization population is successfully done');
 }