autoSubscriptionService = $autoSubscriptionService; $this->autoSubscriptionGateway = $autoSubscriptionGateway; $this->subscriptionCycleArticleService = $subscriptionCycleArticleService; $this->businessLetterWrapper = $businessLetterWrapper; } /** * @param SubscriptionCycleAutoSubscriptionData $autosubscription * * @throws ValidationFailedException */ public function saveNewAutoSubscription(SubscriptionCycleAutoSubscriptionData $autosubscription): void { $this->autoSubscriptionService->create($autosubscription); } /** * @param SubscriptionCycleAutoSubscriptionData $autosubscription * * @throws ValidationFailedException * @throws AutoSubscriptionNotFoundException */ public function updateAutoSubscription(SubscriptionCycleAutoSubscriptionData $autosubscription): void { $this->autoSubscriptionService->edit($autosubscription); } /** * @param int $autoSubscriptionId * * @throws AutoSubscriptionNotFoundException * * @return SubscriptionCycleAutoSubscriptionData */ public function getAutoSubscriptionById(int $autoSubscriptionId): SubscriptionCycleAutoSubscriptionData { $autosubscription = $this->autoSubscriptionGateway->getById($autoSubscriptionId); return $autosubscription; } /** * @param int $autoSubscriptionId * * @throws AutoSubscriptionNotFoundException * @throws RuntimeException */ public function deleteAutoSubscriptionById(int $autoSubscriptionId): void { $this->autoSubscriptionService->removeById($autoSubscriptionId); } /** * @param int $docId */ public function createSubscription(int $docId): void { $data = $this->autoSubscriptionGateway->findAutoSubscriptionData($docId); if (!empty($data)) { foreach ($data as $d) { $subscriptionArticle = SubscriptionCycleArticleData::fromArray($d); $this->subscriptionCycleArticleService->create($subscriptionArticle); if ($d['prevent_auto_dispatch'] == 1) { $this->autoSubscriptionService->preventAutoDispatch($docId); } } $this->businessLetterWrapper->sendBusinessLetter($data, $docId); } } /** * @param int $docId * * @return bool */ public function hasDocAutoSubscription(int $docId): bool { $data = $this->autoSubscriptionGateway->findAutoSubscriptionData($docId); if (!empty($data)) { return true; } return false; } }