diff --git a/.env b/.env index 6ed906d..85d8816 100644 --- a/.env +++ b/.env @@ -25,3 +25,5 @@ APP_SECRET=aa708f7c537a5c6d167229524aea0817 # IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml DATABASE_URL=mysql://db_user:db_password@127.0.0.1:3306/db_name?serverVersion=5.7 ###< doctrine/doctrine-bundle ### + +APP_DEFAULT_URI=http://127.0.0.1:8000 diff --git a/.gitignore b/.gitignore index 10ed1d3..a1059c8 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,5 @@ /data/ /var/ /vendor/ +/.mage.yml ###< symfony/framework-bundle ### diff --git a/config/packages/framework.yaml b/config/packages/framework.yaml index cad7f78..5bfa315 100644 --- a/config/packages/framework.yaml +++ b/config/packages/framework.yaml @@ -1,6 +1,9 @@ # see https://symfony.com/doc/current/reference/configuration/framework.html framework: secret: '%env(APP_SECRET)%' + router: + default_uri: '%env(APP_DEFAULT_URI)%' + #csrf_protection: true #http_method_override: true diff --git a/src/Command/MailingListCommand.php b/src/Command/MailingListCommand.php index ff18fb1..6f49068 100644 --- a/src/Command/MailingListCommand.php +++ b/src/Command/MailingListCommand.php @@ -9,6 +9,8 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; use App\Repository\MailingRepository; +use Symfony\Component\Routing\RouterInterface; +use Symfony\Component\Routing\Generator\UrlGeneratorInterface; class MailingListCommand extends Command { @@ -16,11 +18,14 @@ class MailingListCommand extends Command protected MailingRepository $repo; - public function __construct(MailingRepository $repo) + protected RouterInterface $router; + + public function __construct(MailingRepository $repo, RouterInterface $router) { parent::__construct(); $this->repo = $repo; + $this->router = $router; } protected function configure() @@ -34,7 +39,7 @@ class MailingListCommand extends Command { $io = new SymfonyStyle($input, $output); - $headers = ['Label', 'ID', 'Created at', 'Updated at']; + $headers = ['Label', 'Feed', 'Created at', 'Updated at']; $rows = []; $entities = $this->repo->findAll([], ['createdAt' => 'DEC']); @@ -42,7 +47,11 @@ class MailingListCommand extends Command foreach ($entities as $entity) { $rows[] = [ $entity->getLabel(), - $entity->getId(), + $this->router->generate( + 'mailing_rss', + ['id' => $entity->getId()], + UrlGeneratorInterface::ABSOLUTE_URL + ), $entity->getCreatedAt()->format('Y-m-d H:i:s'), $entity->getUpdatedAt()->format('Y-m-d H:i:s'), ]; diff --git a/src/Controller/MailingController.php b/src/Controller/MailingController.php index 1cf80d3..c983498 100644 --- a/src/Controller/MailingController.php +++ b/src/Controller/MailingController.php @@ -16,7 +16,7 @@ class MailingController extends AbstractController */ public function rss(Mailing $mailing, MailRepository $mailRepository): Response { - $mails = $mailRepository->findAll( + $mails = $mailRepository->findBy( [ 'mailing' => $mailing->getId(), ],