/** * {@inheritdoc} * @return SubscriptionInterface * @throws InvalidItemException */ public function reverseTransform(OrderItemInterface $item) { if (!$this->supports($item)) { throw new InvalidItemException('Unsupported order item.'); } return $this->repository->findOneBy(['id' => $item->getSubjectData()['id']]); }
/** * Feeds the order with all the user "payment required" subscriptions. * * @param OrderInterface $order * @param UserInterface $user * @throws \Exception * @throws \Ekyna\Bundle\SubscriptionBundle\Exception\SubscriptionException */ public function feed(OrderInterface $order, UserInterface $user) { $subscriptions = $this->repository->findByUserAndPaymentRequired($user); if (empty($subscriptions)) { throw new NoPaymentRequiredSubscriptionException(); } foreach ($subscriptions as $subscription) { // Don't add twice if ($this->orderHelper->hasSubject($order, $subscription)) { continue; } try { $event = $this->orderHelper->addSubject($order, $subscription); if ($event->isPropagationStopped()) { throw new OrderFeedFailureException(); } } catch (\Exception $e) { if ($this->debug) { throw $e; } throw new OrderFeedFailureException(); } } }
/** * {@inheritdoc} */ public function getAdminShowTab(UserInterface $user) { $data = ['subscriptions' => $this->subscriptionRepository->findByUser($user), 'create_order' => $this->subscriptionRepository->userHasPaymentRequiredSubscriptions($user)]; return new ShowTab('ekyna_subscription.label', $data, 'EkynaSubscriptionBundle:Admin/User:subscription_tab.html.twig'); }