You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

46 lines
1.0 KiB

  1. <?php
  2. namespace App\Command;
  3. use App\Repository\FeedRepository;
  4. use App\Service\FeedEntriesImporter;
  5. use Symfony\Component\Console\Command\Command;
  6. use Symfony\Component\Console\Input\InputInterface;
  7. use Symfony\Component\Console\Output\OutputInterface;
  8. class ImportFeedEntriesCommand extends Command
  9. {
  10. /**
  11. * @var FeedEntriesImporter
  12. */
  13. private $importer;
  14. /**
  15. * @var FeedRepository
  16. */
  17. private $repository;
  18. public function __construct(
  19. FeedEntriesImporter $importer,
  20. FeedRepository $repository
  21. ) {
  22. parent::__construct();
  23. $this->importer = $importer;
  24. $this->repository = $repository;
  25. }
  26. protected function configure()
  27. {
  28. $this->setDescription('Imports new entries from all known feeds.');
  29. }
  30. protected function execute(InputInterface $input, OutputInterface $output): int
  31. {
  32. foreach ($this->repository->findAll() as $feed) {
  33. $this->importer->importEntries($feed);
  34. }
  35. return 0;
  36. }
  37. }