Bonjour à tous,
Voilà j'ai un projet avec docker et supervisor qui run un cron ça marche nickel je le voit au log, par contre quand j'ajoute ma classe en paramètre qui est mappé dans mon service.yml le cron bloque pourtant dans un autre projet cela fonctionne parfaitement.
le service.yml j'ai cette ligne:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100 <?php namespace App\Command; use App\Dao\ContactInformation; use App\Entity\CronJobData; use App\Service\NotificationApi; use Doctrine\ORM\EntityManagerInterface; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; use App\Repository\CronJobDataRepository; class CronNotificationCommand extends Command { protected static $defaultName = 'cron:notification'; private $notification; private $idCurrentCronData; public function __construct(EntityManagerInterface $em, NotificationApi $notification) { parent::__construct(); $this->em = $em; $this->notification = $notification; } protected function configure() { $this ->setDescription('Permit to send notificaton by cron job cron:notification') ->addArgument('keyMailjet', InputArgument::REQUIRED, 'see key in avaibles in EnumKeyMailjetId') ; } protected function execute(InputInterface $input, OutputInterface $output): int { $io = new SymfonyStyle($input, $output); $keyMailjet = (string)$input->getArgument('keyMailjet'); $contact = $this->getContactInformation($keyMailjet); dd($contact); if($contact) { $response = $this->notification->sendNotification( $keyMailjet, $contact ); $this->disableContactData($this->idCurrentCronData); $io->success('Cron currently work!'); return 0; } $io->note('No data to send!'); return -1; } /** * get contact information for notification * * @param string $keyMailjet * @return ContactInformation|null */ private function getContactInformation(string $keyMailjet) : ?ContactInformation { // get active data and for the cron pass like parameter $contact = $this->em->getRepository(CronJobData::class)->findOneBy( ['active' => true, 'origin' => $keyMailjet], ['id' => 'DESC'] ); // no active data for this key if(empty($contact)) throw new \Exception("no active data for this key!"); $this->idCurrentCronData = $contact->getId(); $contactInformation= new ContactInformation( $contact->getContactInformation() ); return $contactInformation; } /** * Disable cron Data no selected in the next notification * * @param integer $id cron Data id to disable * @return void */ private function disableContactData(int $id) { $cronData = $this->em->getRepository(CronJobData::class)->find($id); $cronData->setActive(false); $this->em->persist($cronData); $this->em->flush(); } }
je ne comprends pas la classe dans un autre projet symfony est mappé exactement pareil mais ça ne fonctionne pas
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 services: App\Service\NotificationApi:.
merci de votre aide
Partager