public function RecurringOrderManager::collectSubscriptions in Commerce Recurring Framework 8
Collects all subscriptions that belong to an order.
Parameters
\Drupal\commerce_order\Entity\OrderInterface $order: The order.
Return value
\Drupal\commerce_recurring\Entity\SubscriptionInterface[] The subscriptions.
Overrides RecurringOrderManagerInterface::collectSubscriptions
3 calls to RecurringOrderManager::collectSubscriptions()
- RecurringOrderManager::closeOrder in src/
RecurringOrderManager.php - Closes the given recurring order.
- RecurringOrderManager::refreshOrder in src/
RecurringOrderManager.php - Refreshes the given recurring order.
- RecurringOrderManager::renewOrder in src/
RecurringOrderManager.php - Renews the given recurring order.
File
- src/
RecurringOrderManager.php, line 216
Class
- RecurringOrderManager
- Provides the default recurring order manager.
Namespace
Drupal\commerce_recurringCode
public function collectSubscriptions(OrderInterface $order) {
$subscriptions = [];
foreach ($order
->getItems() as $order_item) {
if ($order_item
->get('subscription')
->isEmpty()) {
// A recurring order item without a subscription ID is malformed.
continue;
}
/** @var \Drupal\commerce_recurring\Entity\SubscriptionInterface $subscription */
$subscription = $order_item
->get('subscription')->entity;
// Guard against deleted subscription entities.
if ($subscription) {
$subscriptions[$subscription
->id()] = $subscription;
}
}
return $subscriptions;
}