Vous ne pouvez pas sélectionner plus de 25 sujets
Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
|
- <?php
-
- namespace domain\Communication\AutomaticEmail;
-
- use domain\_\AbstractResolver;
- use domain\Distribution\Distribution\Distribution;
- use domain\Distribution\Distribution\DistributionRepository;
- use domain\Producer\Producer\ProducerSolver;
-
- class AutomaticEmailResolver extends AbstractResolver
- {
- protected DistributionRepository $distributionRepository;
- protected ProducerSolver $producerSolver;
-
- public function loadDependencies(): void
- {
- $this->distributionRepository = $this->loadService(DistributionRepository::class);
- $this->producerSolver = $this->loadService(ProducerSolver::class);
- }
-
- public function getMatchedDistribution(AutomaticEmail $automaticEmail): ?Distribution
- {
- $date = (new \DateTime('+'.$automaticEmail->getDelayBeforeDistribution().' days'));
- $dateFormat = $date->format('Y-m-d');
- $distribution = $this->distributionRepository->findOneDistribution($dateFormat);
-
- if($distribution
- && $distribution->active
- && $date->format('N') == $automaticEmail->getDay()
- && !$this->producerSolver->isOnLeavePeriodByDistribution($distribution)) {
- return $distribution;
- }
-
- return null;
- }
- }
|