/** * @inheritdoc */ public function run(IOutput $output) { $output->startProgress(); $this->userManager->callForAllUsers(function ($user) use($output) { /** @var IUser $user */ $output->advance(1, $user->getDisplayName()); $this->birthdayService->syncUser($user->getUID()); }); $output->finishProgress(); }
/** * @param InputInterface $input * @param OutputInterface $output */ protected function execute(InputInterface $input, OutputInterface $output) { $user = $input->getArgument('user'); if (!is_null($user)) { if (!$this->userManager->userExists($user)) { throw new \InvalidArgumentException("User <{$user}> in unknown."); } $output->writeln("Start birthday calendar sync for {$user}"); $this->birthdayService->syncUser($user); return; } $output->writeln("Start birthday calendar sync for all users ..."); $p = new ProgressBar($output); $p->start(); $this->userManager->callForAllUsers(function ($user) use($p) { $p->advance(); /** @var IUser $user */ $this->birthdayService->syncUser($user->getUID()); }); $p->finish(); $output->writeln(''); }