/** * @param SubscriptionSelectCommand $message * * @throws \Baboon\SubscriptionBundle\Exception\PackageNotFoundException */ public function selectSubscription(SubscriptionSelectCommand $message) { if (null === ($package = $this->packageManager->findPackageByAlias($message->package))) { throw new PackageNotFoundException($message->package); } $subscription = $this->subscriptionProvider->getSubscription(); if (null === $subscription) { $subscription = $this->subscriptionManager->createSubscription(); } $subscription->select($package); $this->subscriptionManager->updateSubscription($subscription); $this->eventRecorder->record(new SubscriptionSelectedEvent($subscription)); }