Nie możesz wybrać więcej, niż 25 tematów
Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
|
- <?php
-
- namespace domain\Subscription\Subscription;
-
- use domain\Distribution\Distribution\DistributionRepository;
- use domain\Subscription\ProductSubscription\ProductSubscription;
- use domain\User\User\User;
- use domain\_\AbstractBuilder;
-
- class SubscriptionBuilder extends AbstractBuilder
- {
- protected DistributionRepository $distributionRepository;
-
- public function loadDependencies(): void
- {
- $this->distributionRepository = $this->loadService(DistributionRepository::class);
- }
-
- public function instanciateSubscription(User $createdBy): Subscription
- {
- $subscription = new Subscription();
- $subscription->auto_payment = Subscription::AUTO_PAYMENT_DEDUCTED;
- $subscription->populateCreatedBy($createdBy);
-
- return $subscription;
- }
-
- public function createSubscription(User $createdBy): Subscription
- {
- $subscription = $this->instanciateSubscription($createdBy);
- $this->create($subscription);
-
- return $subscription;
- }
-
- public function deleteSubscription(Subscription $subscription): void
- {
- ProductSubscription::deleteAll(['id_subscription' => $subscription->id]);
- $this->delete($subscription);
- }
- }
|