Du kannst nicht mehr als 25 Themen auswählen
Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
|
- <?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;
- }
- }
|