No puede seleccionar más de 25 temas
Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
|
- <?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;
- }
- }
|