folderService = $folderService; $this->itemService = $itemService; } /** * Configure command * * @return void */ protected function configure(): void { $this->setName('news:folder:read') ->setDescription('Read folder') ->addArgument('user-id', InputArgument::REQUIRED, 'User to modify the folder for') ->addArgument('id', InputArgument::REQUIRED, 'Folder ID'); } /** * Execute command * * @param InputInterface $input * @param OutputInterface $output * * @return int */ protected function execute(InputInterface $input, OutputInterface $output): int { $user = $input->getArgument('user-id'); $id = $input->getArgument('id'); if (!is_numeric($id)) { $output->writeln('Invalid id!'); return 255; } try { $read = $this->folderService->read($user, intval($id)); $output->writeln("Marked $read items as read", $output::VERBOSITY_VERBOSE); } catch (ServiceConflictException | ServiceNotFoundException $e) { $output->writeln('Failed: ' . $e->getMessage()); return 0; } return 0; } }