Skip to content

Commit

Permalink
Use PHP 8 AsCommand attribute for app:prices:check command
Browse files Browse the repository at this point in the history
  • Loading branch information
duboiss committed Oct 11, 2021
1 parent 02931e6 commit 682c66b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"symfony/css-selector": "5.3.*",
"symfony/dom-crawler": "5.3.*",
"symfony/dotenv": "5.3.*",
"symfony/event-dispatcher": "5.3.*",
"symfony/finder": "5.3.*",
"symfony/flex": "^1.3.1",
"symfony/framework-bundle": "5.3.*",
Expand Down
2 changes: 1 addition & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 2 additions & 6 deletions src/Command/CheckPricesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,23 @@

use App\Event\ProductParsedEvent;
use App\Service\ProductService;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Finder\Finder;

#[AsCommand('app:prices:check', description: 'Check all prices in urls provided by DataProducts directory')]
class CheckPricesCommand extends Command
{
protected static $defaultName = 'app:prices:check';
private const PRODUCTS_PATH = __DIR__ . '/../DataProducts';

public function __construct(private ProductService $productService, private EventDispatcherInterface $dispatcher)
{
parent::__construct();
}

protected function configure(): void
{
$this->setDescription('Check all prices in urls provided by DataProducts directory');
}

protected function execute(InputInterface $input, OutputInterface $output): int
{
$this->dispatcher->addListener(ProductParsedEvent::class, function (ProductParsedEvent $event) use ($output): void {
Expand Down

0 comments on commit 682c66b

Please sign in to comment.