Add Filter options to the TestFeed command
This commit is contained in:
		
							parent
							
								
									78ed53d529
								
							
						
					
					
						commit
						6b053d5cb4
					
				| @ -8,6 +8,7 @@ use Symfony\Component\Console\{Attribute\AsCommand, | ||||
|     Command\Command, | ||||
|     Input\InputArgument, | ||||
|     Input\InputInterface, | ||||
|     Input\InputOption, | ||||
|     Output\OutputInterface}; | ||||
| use Doctrine\Common\Collections\ArrayCollection; | ||||
| use Doctrine\ORM\EntityManager; | ||||
| @ -29,9 +30,13 @@ class TestFeed extends Command | ||||
| 
 | ||||
|     protected function configure(): void | ||||
|     { | ||||
|         $optional_array = InputOption::VALUE_IS_ARRAY|InputOption::VALUE_OPTIONAL; | ||||
|         $this | ||||
|             ->addArgument("url", InputArgument::REQUIRED, "The URL of the feed to test") | ||||
|             ->addArgument("title", InputArgument::REQUIRED, "The title of the feed to test"); | ||||
|             ->addArgument("title", InputArgument::REQUIRED, "The title of the feed to test") | ||||
|             ->addOption("filter", "f", $optional_array, "Filter Types to apply to the feed", []) | ||||
|             ->addOption("target", "t", $optional_array, "Targets to apply the filters to", []) | ||||
|             ->addOption("value", "a", $optional_array, "Values to apply the filters to", []); | ||||
|     } | ||||
| 
 | ||||
|     protected function execute(InputInterface $input, OutputInterface $output): int | ||||
| @ -50,9 +55,13 @@ class TestFeed extends Command | ||||
|         $feed->url = $url; | ||||
|         $feed->title = $title; | ||||
| 
 | ||||
|         $filters = array_map(null, $input->getOption("target"), $input->getOption("filter"), $input->getOption("value")); | ||||
| 
 | ||||
|         $feed->feedFilters = new ArrayCollection(); | ||||
|         $feed->feedFilters->add( new FeedFilter(FilterTarget::TITLE, FilterType::INCLUDE, "[No Ads]", $feed)); | ||||
|         $feed->feedFilters->add( new FeedFilter(FilterTarget::TITLE, FilterType::EXCLUDE, "S2", $feed)); | ||||
| 
 | ||||
|         foreach ($filters as $filter) { | ||||
|             $feed->feedFilters->add(new FeedFilter(FilterTarget::from($filter[0]), FilterType::from($filter[1]), $filter[2], $feed)); | ||||
|         } | ||||
| 
 | ||||
|         $this->em->persist($feed); | ||||
|         $this->em->flush(); | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user