|
@@ -1,42 +0,0 @@
|
|
|
-<?php
|
|
|
-
|
|
|
-namespace App\Command;
|
|
|
-
|
|
|
-use App\Repository\ArticleRepository;
|
|
|
-use App\Service\SluggerService;
|
|
|
-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\Console\Style\SymfonyStyle;
|
|
|
-
|
|
|
-#[AsCommand(
|
|
|
- name: 'blog:slug:init',
|
|
|
- description: 'Add a short description for your command',
|
|
|
-)]
|
|
|
-class BlogSlugInitCommand extends Command
|
|
|
-{
|
|
|
- public function __construct(
|
|
|
- protected readonly SluggerService $sluggerService,
|
|
|
- protected readonly ArticleRepository $articleRepository
|
|
|
- )
|
|
|
- {
|
|
|
- parent::__construct();
|
|
|
- }
|
|
|
-
|
|
|
- protected function execute(InputInterface $input, OutputInterface $output): int
|
|
|
- {
|
|
|
- $io = new SymfonyStyle($input, $output);
|
|
|
-
|
|
|
- $this->sluggerService->generateSlugsForExistingArticles();
|
|
|
-
|
|
|
- $articles = $this->articleRepository->findAll();
|
|
|
- foreach($articles as $article) {
|
|
|
- $io->text(sprintf('Article : %s / Slug : %s', $article->getTitle(), $article->getSlug()));
|
|
|
- }
|
|
|
-
|
|
|
- $io->success('Les slugs sont générés');
|
|
|
-
|
|
|
- return Command::SUCCESS;
|
|
|
- }
|
|
|
-}
|