Ви не можете вибрати більше 25 тем
Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
|
- <?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;
- }
- }
|