public function subscribe(UserInterface $user, PlanInterface $plan) { $subscription = new $this->class(); $subscription->setName($plan->getName())->setCurrency($plan->getCurrency())->setPrice($plan->getPrice())->setDiscount($plan->getDiscount())->setPlan($plan); $user->addSubscription($subscription); $this->event_dispatcher->dispatch(SaaSEvents::SUBSCRIBED, new SubscriptionEvent($subscription)); return $subscription; }