public function LicenseSubscription::onSubscriptionExpire in Commerce License 8.2
Acts on a subscription after it has expired.
Called before the subscription is saved.
Parameters
\Drupal\commerce_recurring\Entity\SubscriptionInterface $subscription: The subscription.
Overrides SubscriptionTypeBase::onSubscriptionExpire
File
- src/
Plugin/ Commerce/ SubscriptionType/ LicenseSubscription.php, line 93
Class
- LicenseSubscription
- Provides a Commerce Recurring subscription type for use with licenses.
Namespace
Drupal\commerce_license\Plugin\Commerce\SubscriptionTypeCode
public function onSubscriptionExpire(SubscriptionInterface $subscription) {
$license = $subscription->license->entity;
// Change the license's state to expired.
// The License entity will handle deactivating the license type plugin.
$transition = $license
->getState()
->getWorkflow()
->getTransition('expire');
$license
->getState()
->applyTransition($transition);
$license
->save();
}