class Subscription in Commerce Recurring Framework 8
Defines the subscription entity.
Plugin annotation
@ContentEntityType(
id = "commerce_subscription",
label = @Translation("Subscription"),
label_collection = @Translation("Subscriptions"),
label_singular = @Translation("subscription"),
label_plural = @Translation("subscriptions"),
label_count = @PluralTranslation(
singular = "@count subscription",
plural = "@count subscription",
),
bundle_label = @Translation("Subscription type"),
bundle_plugin_type = "commerce_subscription_type",
handlers = {
"event" = "Drupal\commerce_recurring\Event\SubscriptionEvent",
"list_builder" = "Drupal\commerce_recurring\SubscriptionListBuilder",
"storage" = "\Drupal\commerce_recurring\SubscriptionStorage",
"access" = "Drupal\commerce_recurring\SubscriptionAccessControlHandler",
"permission_provider" = "Drupal\commerce_recurring\SubscriptionPermissionProvider",
"query_access" = "Drupal\entity\QueryAccess\UncacheableQueryAccessHandler",
"form" = {
"default" = "\Drupal\commerce_recurring\Form\SubscriptionForm",
"edit" = "\Drupal\commerce_recurring\Form\SubscriptionForm",
"customer" = "\Drupal\commerce_recurring\Form\SubscriptionForm",
"delete" = "\Drupal\commerce_recurring\Form\SubscriptionDeleteForm",
"cancel" = "\Drupal\commerce_recurring\Form\SubscriptionCancelForm",
},
"views_data" = "Drupal\commerce_recurring\SubscriptionViewsData",
"route_provider" = {
"default" = "Drupal\commerce_recurring\SubscriptionRouteProvider",
},
},
base_table = "commerce_subscription",
admin_permission = "administer commerce_subscription",
fieldable = TRUE,
entity_keys = {
"id" = "subscription_id",
"bundle" = "type",
"uuid" = "uuid",
"owner" = "uid",
},
links = {
"canonical" = "/admin/commerce/subscriptions/{commerce_subscription}",
"add-page" = "/admin/commerce/subscriptions/add",
"add-form" = "/admin/commerce/subscriptions/{type}/add",
"edit-form" = "/admin/commerce/subscriptions/{commerce_subscription}/edit",
"customer-view" = "/user/{user}/subscriptions/{commerce_subscription}",
"customer-edit-form" = "/user/{user}/subscriptions/{commerce_subscription}/edit",
"delete-form" = "/admin/commerce/subscriptions/{commerce_subscription}/delete",
"collection" = "/admin/commerce/subscriptions",
"cancel-form" = "/admin/commerce/subscriptions/{commerce_subscription}/cancel",
},
field_ui_base_route = "entity.commerce_subscription.admin_form",
)
Hierarchy
- class \Drupal\Core\Entity\EntityBase implements EntityInterface uses RefinableCacheableDependencyTrait, DependencySerializationTrait
- class \Drupal\Core\Entity\ContentEntityBase implements \Drupal\Core\Entity\IteratorAggregate, ContentEntityInterface, TranslationStatusInterface uses EntityChangesDetectionTrait, SynchronizableEntityTrait
- class \Drupal\commerce_recurring\Entity\Subscription implements SubscriptionInterface uses EntityOwnerTrait
- class \Drupal\Core\Entity\ContentEntityBase implements \Drupal\Core\Entity\IteratorAggregate, ContentEntityInterface, TranslationStatusInterface uses EntityChangesDetectionTrait, SynchronizableEntityTrait
Expanded class hierarchy of Subscription
15 files declare their use of Subscription
- BillingScheduleAccessTest.php in tests/
src/ Kernel/ BillingScheduleAccessTest.php - BillingScheduleTest.php in tests/
src/ FunctionalJavascript/ BillingScheduleTest.php - CronTest.php in tests/
src/ Kernel/ CronTest.php - OrderRefreshTest.php in tests/
src/ Kernel/ OrderRefreshTest.php - PaymentDeclinedMailTest.php in tests/
src/ Kernel/ Mail/ PaymentDeclinedMailTest.php
6 string references to 'Subscription'
- commerce_recurring.commerce_adjustment_types.yml in ./
commerce_recurring.commerce_adjustment_types.yml - commerce_recurring.commerce_adjustment_types.yml
- commerce_recurring.workflow_groups.yml in ./
commerce_recurring.workflow_groups.yml - commerce_recurring.workflow_groups.yml
- field.field.commerce_order_item.recurring_product_variation.subscription.yml in config/
optional/ field.field.commerce_order_item.recurring_product_variation.subscription.yml - config/optional/field.field.commerce_order_item.recurring_product_variation.subscription.yml
- field.field.commerce_order_item.recurring_standalone.subscription.yml in config/
install/ field.field.commerce_order_item.recurring_standalone.subscription.yml - config/install/field.field.commerce_order_item.recurring_standalone.subscription.yml
- views.view.commerce_subscription_orders_admin.yml in config/
install/ views.view.commerce_subscription_orders_admin.yml - config/install/views.view.commerce_subscription_orders_admin.yml
File
- src/
Entity/ Subscription.php, line 77
Namespace
Drupal\commerce_recurring\EntityView source
class Subscription extends ContentEntityBase implements SubscriptionInterface {
use EntityOwnerTrait;
/**
* {@inheritdoc}
*/
protected function urlRouteParameters($rel) {
$uri_route_parameters = parent::urlRouteParameters($rel);
$uri_route_parameters['user'] = $this
->getOwnerId();
return $uri_route_parameters;
}
/**
* {@inheritdoc}
*/
public function label() {
return new FormattableMarkup('@title #@id', [
'@title' => $this
->getTitle(),
'@id' => $this
->id(),
]);
}
/**
* {@inheritdoc}
*/
public function getType() {
$subscription_type_manager = \Drupal::service('plugin.manager.commerce_subscription_type');
return $subscription_type_manager
->createInstance($this
->bundle());
}
/**
* {@inheritdoc}
*/
public function getStore() {
return $this
->get('store_id')->entity;
}
/**
* {@inheritdoc}
*/
public function getStoreId() {
return $this
->get('store_id')->target_id;
}
/**
* {@inheritdoc}
*/
public function getBillingSchedule() {
return $this
->get('billing_schedule')->entity;
}
/**
* {@inheritdoc}
*/
public function setBillingSchedule(BillingScheduleInterface $billing_schedule) {
$this
->set('billing_schedule', $billing_schedule);
return $this;
}
/**
* {@inheritdoc}
*/
public function getCustomer() {
return $this
->get('uid')->entity;
}
/**
* {@inheritdoc}
*/
public function setCustomer(UserInterface $account) {
$this
->set('uid', $account
->id());
return $this;
}
/**
* {@inheritdoc}
*/
public function getCustomerId() {
return $this
->get('uid')->target_id;
}
/**
* {@inheritdoc}
*/
public function setCustomerId($uid) {
$this
->set('uid', $uid);
return $this;
}
/**
* {@inheritdoc}
*/
public function getPaymentMethod() {
return $this
->get('payment_method')->entity;
}
/**
* {@inheritdoc}
*/
public function setPaymentMethod(PaymentMethodInterface $payment_method) {
$this
->set('payment_method', $payment_method);
return $this;
}
/**
* {@inheritdoc}
*/
public function getPaymentMethodId() {
return $this
->get('payment_method')->target_id;
}
/**
* {@inheritdoc}
*/
public function setPaymentMethodId($payment_method_id) {
$this
->set('payment_method', $payment_method_id);
return $this;
}
/**
* {@inheritdoc}
*/
public function hasPurchasedEntity() {
return !$this
->get('purchased_entity')
->isEmpty();
}
/**
* {@inheritdoc}
*/
public function getPurchasedEntity() {
return $this
->get('purchased_entity')->entity;
}
/**
* {@inheritdoc}
*/
public function getPurchasedEntityId() {
return $this
->get('purchased_entity')->target_id;
}
/**
* {@inheritdoc}
*/
public function setPurchasedEntity(PurchasableEntityInterface $purchased_entity) {
$this
->set('purchased_entity', $purchased_entity);
return $this;
}
/**
* {@inheritdoc}
*/
public function getTitle() {
return $this
->get('title')->value;
}
/**
* {@inheritdoc}
*/
public function setTitle($title) {
$this
->set('title', $title);
return $this;
}
/**
* {@inheritdoc}
*/
public function getQuantity() {
return (string) $this
->get('quantity')->value;
}
/**
* {@inheritdoc}
*/
public function setQuantity($quantity) {
$this
->set('quantity', (string) $quantity);
return $this;
}
/**
* {@inheritdoc}
*/
public function getUnitPrice() {
if (!$this
->get('unit_price')
->isEmpty()) {
return $this
->get('unit_price')
->first()
->toPrice();
}
}
/**
* {@inheritdoc}
*/
public function setUnitPrice(Price $unit_price) {
$this
->set('unit_price', $unit_price);
return $this;
}
/**
* {@inheritdoc}
*/
public function getState() {
return $this
->get('state')
->first();
}
/**
* {@inheritdoc}
*/
public function setState($state_id) {
$this
->set('state', $state_id);
return $this;
}
/**
* {@inheritdoc}
*/
public function getInitialOrder() {
return $this
->get('initial_order')->entity;
}
/**
* {@inheritdoc}
*/
public function setInitialOrder(OrderInterface $initial_order) {
$this
->set('initial_order', $initial_order);
return $this;
}
/**
* {@inheritdoc}
*/
public function getInitialOrderId() {
return $this
->get('initial_order')->target_id;
}
/**
* {@inheritdoc}
*/
public function getCurrentOrder() {
$order_ids = $this
->getOrderIds();
if (empty($order_ids)) {
return NULL;
}
$order_storage = $this
->entityTypeManager()
->getStorage('commerce_order');
$order_ids = $order_storage
->getQuery()
->condition('type', 'recurring')
->condition('order_id', $order_ids, 'IN')
->condition('state', 'draft')
->sort('order_id', 'DESC')
->accessCheck(FALSE)
->range(0, 1)
->execute();
if (!$order_ids) {
return NULL;
}
return $order_storage
->load(key($order_ids));
}
/**
* {@inheritdoc}
*/
public function getOrderIds() {
$order_ids = [];
foreach ($this
->get('orders') as $field_item) {
$order_ids[] = $field_item->target_id;
}
return $order_ids;
}
/**
* {@inheritdoc}
*/
public function getOrders() {
return $this
->get('orders')
->referencedEntities();
}
/**
* {@inheritdoc}
*/
public function setOrders(array $orders) {
$this
->set('orders', $orders);
return $this;
}
/**
* {@inheritdoc}
*/
public function addOrder(OrderInterface $order) {
if (!$this
->hasOrder($order)) {
$this
->get('orders')
->appendItem($order);
}
return $this;
}
/**
* {@inheritdoc}
*/
public function removeOrder(OrderInterface $order) {
$index = $this
->getOrderIndex($order);
if ($index !== FALSE) {
$this
->get('orders')
->offsetUnset($index);
}
return $this;
}
/**
* {@inheritdoc}
*/
public function hasOrder(OrderInterface $order) {
return $this
->getOrderIndex($order) !== FALSE;
}
/**
* Gets the index of the given recurring order.
*
* @param \Drupal\commerce_order\Entity\OrderInterface $order
* The recurring order.
*
* @return int|bool
* The index of the given recurring order, or FALSE if not found.
*/
protected function getOrderIndex(OrderInterface $order) {
$values = $this
->get('orders')
->getValue();
$order_ids = array_map(function ($value) {
return $value['target_id'];
}, $values);
return array_search($order
->id(), $order_ids);
}
/**
* {@inheritdoc}
*/
public function getCreatedTime() {
return $this
->get('created')->value;
}
/**
* {@inheritdoc}
*/
public function setCreatedTime($timestamp) {
$this
->set('created', $timestamp);
return $this;
}
/**
* {@inheritdoc}
*/
public function getNextRenewalTime() {
return $this
->get('next_renewal')->value;
}
/**
* {@inheritdoc}
*/
public function setNextRenewalTime($timestamp) {
$this
->set('next_renewal', $timestamp);
return $this;
}
/**
* {@inheritdoc}
*/
public function getNextRenewalDate() {
if ($next_renewal_time = $this
->getNextRenewalTime()) {
return DrupalDateTime::createFromTimestamp($next_renewal_time);
}
}
/**
* {@inheritdoc}
*/
public static function postDelete(EntityStorageInterface $storage, array $entities) {
parent::postDelete($storage, $entities);
// Delete the orders of a deleted subscription. Otherwise they will
// reference an invalid subscription and result in data integrity issues.
// Deleting the orders will also remove all order items.
$orders = [];
/** @var \Drupal\commerce_recurring\Entity\SubscriptionInterface $entity */
foreach ($entities as $entity) {
foreach ($entity
->getOrders() as $order) {
$orders[$order
->id()] = $order;
}
}
/** @var \Drupal\commerce_order\OrderStorage $order_storage */
$order_storage = \Drupal::service('entity_type.manager')
->getStorage('commerce_order');
$order_storage
->delete($orders);
}
/**
* {@inheritdoc}
*/
public function getRenewedTime() {
return $this
->get('renewed')->value;
}
/**
* {@inheritdoc}
*/
public function setRenewedTime($timestamp) {
$this
->set('renewed', $timestamp);
return $this;
}
/**
* {@inheritdoc}
*/
public function getTrialStartTime() {
return $this
->get('trial_starts')->value;
}
/**
* {@inheritdoc}
*/
public function setTrialStartTime($timestamp) {
$this
->set('trial_starts', $timestamp);
return $this;
}
/**
* {@inheritdoc}
*/
public function getTrialEndTime() {
return $this
->get('trial_ends')->value;
}
/**
* {@inheritdoc}
*/
public function setTrialEndTime($timestamp) {
$this
->set('trial_ends', $timestamp);
return $this;
}
/**
* {@inheritdoc}
*/
public function getTrialStartDate() {
return DrupalDateTime::createFromTimestamp($this
->getTrialStartTime());
}
/**
* {@inheritdoc}
*/
public function getTrialEndDate() {
if ($end_time = $this
->getTrialEndTime()) {
return DrupalDateTime::createFromTimestamp($end_time);
}
}
/**
* {@inheritdoc}
*/
public function getStartTime() {
return $this
->get('starts')->value;
}
/**
* {@inheritdoc}
*/
public function setStartTime($timestamp) {
$this
->set('starts', $timestamp);
return $this;
}
/**
* {@inheritdoc}
*/
public function getEndTime() {
return $this
->get('ends')->value;
}
/**
* {@inheritdoc}
*/
public function setEndTime($timestamp) {
$this
->set('ends', $timestamp);
return $this;
}
/**
* {@inheritdoc}
*/
public function getStartDate() {
return DrupalDateTime::createFromTimestamp($this
->getStartTime());
}
/**
* {@inheritdoc}
*/
public function getEndDate() {
if ($end_time = $this
->getEndTime()) {
return DrupalDateTime::createFromTimestamp($end_time);
}
}
/**
* {@inheritdoc}
*/
public function getCurrentBillingPeriod() {
if ($current_order = $this
->getCurrentOrder()) {
if (!$current_order
->get('billing_period')
->isEmpty()) {
return $current_order
->get('billing_period')
->first()
->toBillingPeriod();
}
}
return NULL;
}
/**
* {@inheritdoc}
*/
public function hasScheduledChanges() {
return !$this
->get('scheduled_changes')
->isEmpty();
}
/**
* {@inheritdoc}
*/
public function getScheduledChanges() {
return $this
->get('scheduled_changes')
->getScheduledChanges();
}
/**
* {@inheritdoc}
*/
public function setScheduledChanges(array $scheduled_changes) {
$this
->set('scheduled_changes', $scheduled_changes);
return $this;
}
/**
* {@inheritdoc}
*/
public function addScheduledChange($field_name, $value) {
if (!$this
->hasField($field_name)) {
throw new \InvalidArgumentException(sprintf('Invalid field_name "%s" specified for the given scheduled change.', $field_name));
}
if ($field_name === 'purchased_entity') {
throw new \InvalidArgumentException('Scheduling a plan change is not yet supported.');
}
// Other scheduled changes are made irrelevant by a state change.
if ($field_name === 'state') {
$this
->removeScheduledChanges();
}
else {
// There can only be a single scheduled change for a given field.
$this
->removeScheduledChanges($field_name);
}
$scheduled_change = new ScheduledChange($field_name, $value, \Drupal::time()
->getRequestTime());
$this
->get('scheduled_changes')
->appendItem($scheduled_change);
return $this;
}
/**
* {@inheritdoc}
*/
public function removeScheduledChanges($field_name = NULL) {
foreach ($this
->getScheduledChanges() as $scheduled_change) {
if (!$field_name || $scheduled_change
->getFieldName() === $field_name) {
$this
->get('scheduled_changes')
->removeScheduledChange($scheduled_change);
}
}
return $this;
}
/**
* {@inheritdoc}
*/
public function hasScheduledChange($field_name, $value = NULL) {
foreach ($this
->getScheduledChanges() as $change) {
if ($change
->getFieldName() != $field_name) {
continue;
}
if (is_null($value) || $change
->getValue() == $value) {
return TRUE;
}
}
return FALSE;
}
/**
* {@inheritdoc}
*/
public function applyScheduledChanges() {
foreach ($this
->getScheduledChanges() as $scheduled_change) {
$this
->set($scheduled_change
->getFieldName(), $scheduled_change
->getValue());
}
$this
->removeScheduledChanges();
return $this;
}
/**
* {@inheritdoc}
*/
public function cancel($schedule = TRUE) {
if ($schedule) {
$transition = $this
->getState()
->getWorkflow()
->getTransition('cancel');
$state_id = $transition
->getToState()
->getId();
$this
->addScheduledChange('state', $state_id);
}
else {
$this
->getState()
->applyTransitionById('cancel');
}
return $this;
}
/**
* {@inheritdoc}
*/
public function preSave(EntityStorageInterface $storage) {
parent::preSave($storage);
foreach ([
'store_id',
'billing_schedule',
'uid',
'title',
'unit_price',
] as $field) {
if ($this
->get($field)
->isEmpty()) {
throw new EntityMalformedException(sprintf('Required subscription field "%s" is empty.', $field));
}
}
$state = $this
->getState()
->getId();
$original_state = isset($this->original) ? $this->original
->getState()
->getId() : '';
if ($original_state !== $state) {
$this
->removeScheduledChanges();
}
if ($state === 'trial' && $original_state !== 'trial') {
if (empty($this
->getTrialStartTime())) {
$this
->setTrialStartTime(\Drupal::time()
->getRequestTime());
}
if (empty($this
->getTrialEndTime()) && ($billing_schedule = $this
->getBillingSchedule())) {
$billing_schedule_plugin = $billing_schedule
->getPlugin();
if ($billing_schedule_plugin
->allowTrials()) {
$trial_period = $billing_schedule_plugin
->generateTrialPeriod($this
->getTrialStartDate());
$trial_end_time = $trial_period
->getEndDate()
->getTimestamp();
$this
->setTrialEndTime($trial_end_time);
}
}
if (empty($this
->getStartTime()) && !empty($this
->getTrialEndTime())) {
$this
->setStartTime($this
->getTrialEndTime());
}
}
elseif ($state === 'active' && $original_state !== 'active') {
if (empty($this
->getStartTime())) {
$this
->setStartTime(\Drupal::time()
->getRequestTime());
}
if (!empty($this
->getEndTime())) {
$this
->setEndTime(NULL);
}
}
else {
if ($this
->isNew()) {
return;
}
if ($state == 'expired' && $original_state != 'expired') {
$this
->getType()
->onSubscriptionExpire($this);
}
elseif ($state == 'canceled' && $original_state != 'canceled') {
if ($original_state == 'trial') {
$this
->getType()
->onSubscriptionTrialCancel($this);
}
else {
$this
->getType()
->onSubscriptionCancel($this);
}
$this
->setEndTime(\Drupal::time()
->getRequestTime());
}
}
}
/**
* {@inheritdoc}
*/
public function postSave(EntityStorageInterface $storage, $update = TRUE) {
parent::postSave($storage, $update);
$current_order = $this
->getCurrentOrder();
if (!isset($this->original) || empty($current_order)) {
return;
}
$fields_affecting_current_order = [
'payment_method',
'state',
];
foreach ($fields_affecting_current_order as $field_name) {
if (!$this
->get($field_name)
->equals($this->original
->get($field_name))) {
$current_order
->setRefreshState(OrderInterface::REFRESH_ON_SAVE);
$current_order
->save();
break;
}
}
}
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields = parent::baseFieldDefinitions($entity_type);
$fields += static::ownerBaseFieldDefinitions($entity_type);
$fields['store_id'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Store'))
->setDescription(t('The store to which the subscription belongs.'))
->setCardinality(1)
->setRequired(TRUE)
->setSetting('target_type', 'commerce_store')
->setSetting('handler', 'default')
->setDisplayOptions('form', [
'type' => 'commerce_entity_select',
'weight' => 2,
])
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
$fields['billing_schedule'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Billing schedule'))
->setDescription(t('The billing schedule.'))
->setRequired(TRUE)
->setSetting('target_type', 'commerce_billing_schedule')
->setSetting('handler', 'default')
->setDisplayConfigurable('view', TRUE)
->setDisplayOptions('form', [
'type' => 'options_select',
'weight' => 0,
])
->setDisplayConfigurable('form', TRUE);
$fields['uid']
->setLabel(t('Customer'))
->setDescription(t('The subscribed customer.'))
->setRequired(TRUE)
->setDisplayConfigurable('view', TRUE)
->setDisplayOptions('form', [
'type' => 'entity_reference_autocomplete',
'weight' => 0,
])
->setDisplayConfigurable('form', TRUE);
$fields['payment_method'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Payment method'))
->setDescription(t('The payment method.'))
->setSetting('target_type', 'commerce_payment_method')
->setDisplayOptions('form', [
'type' => 'commerce_recurring_payment_method',
'weight' => 0,
])
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE)
->setReadOnly(TRUE);
$fields['purchased_entity'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Purchased entity'))
->setDescription(t('The purchased entity.'))
->setRequired(TRUE)
->setDisplayOptions('form', [
'type' => 'entity_reference_autocomplete',
'weight' => -1,
'settings' => [
'match_operator' => 'CONTAINS',
'size' => '60',
'placeholder' => '',
],
])
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
$fields['title'] = BaseFieldDefinition::create('string')
->setLabel(t('Title'))
->setDescription(t('The subscription title.'))
->setRequired(TRUE)
->setSettings([
'default_value' => '',
'max_length' => 512,
])
->setDisplayOptions('form', [
'type' => 'string_textfield',
'weight' => -10,
])
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
$fields['quantity'] = BaseFieldDefinition::create('decimal')
->setLabel(t('Quantity'))
->setDescription(t('The subscription quantity.'))
->setRequired(TRUE)
->setSetting('unsigned', TRUE)
->setSetting('min', 0)
->setDefaultValue(1)
->setDisplayOptions('form', [
'type' => 'number',
'weight' => 1,
])
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
$fields['unit_price'] = BaseFieldDefinition::create('commerce_price')
->setLabel(t('Unit price'))
->setDescription(t('The subscription unit price.'))
->setRequired(TRUE)
->setDisplayOptions('form', [
'type' => 'commerce_price_default',
'weight' => 2,
])
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
$fields['state'] = BaseFieldDefinition::create('state')
->setLabel(t('State'))
->setDescription(t('The subscription state.'))
->setRequired(TRUE)
->setSetting('max_length', 255)
->setSetting('workflow', 'subscription_default')
->setDisplayOptions('view', [
'label' => 'hidden',
'type' => 'list_default',
'weight' => 0,
])
->setDisplayConfigurable('view', TRUE);
$fields['initial_order'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Initial order'))
->setDescription(t('The non-recurring order which started the subscription.'))
->setSetting('target_type', 'commerce_order')
->setSetting('handler', 'default')
->setSetting('display_description', TRUE)
->setDisplayConfigurable('view', TRUE);
$fields['orders'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Recurring orders'))
->setDescription(t('The recurring orders.'))
->setCardinality(BaseFieldDefinition::CARDINALITY_UNLIMITED)
->setSetting('target_type', 'commerce_order')
->setSetting('handler', 'default')
->setDisplayOptions('view', [
'type' => 'subscription_orders',
'weight' => 0,
])
->setDisplayConfigurable('view', TRUE);
$fields['created'] = BaseFieldDefinition::create('created')
->setLabel(t('Created'))
->setDescription(t('The time when the subscription was created.'))
->setDisplayOptions('view', [
'label' => 'hidden',
'type' => 'timestamp',
'weight' => 0,
])
->setDisplayConfigurable('view', TRUE);
$fields['next_renewal'] = BaseFieldDefinition::create('timestamp')
->setLabel(t('Next renewal'))
->setDescription(t('The next renewal time.'))
->setDefaultValue(0)
->setDisplayOptions('view', [
'label' => 'hidden',
'type' => 'timestamp',
'weight' => 0,
])
->setDisplayConfigurable('view', TRUE);
$fields['renewed'] = BaseFieldDefinition::create('timestamp')
->setLabel(t('Last renewed'))
->setDescription(t('The time when the subscription was last renewed.'))
->setDefaultValue(0)
->setDisplayOptions('view', [
'label' => 'hidden',
'type' => 'timestamp',
'weight' => 0,
])
->setDisplayConfigurable('view', TRUE);
$fields['trial_starts'] = BaseFieldDefinition::create('timestamp')
->setLabel(t('Trial starts'))
->setDescription(t('The time when the subscription trial starts.'))
->setRequired(FALSE)
->setDisplayOptions('view', [
'label' => 'hidden',
'type' => 'timestamp',
'weight' => 0,
])
->setDisplayOptions('form', [
'type' => 'datetime_timestamp',
'weight' => 0,
])
->setDisplayConfigurable('view', TRUE)
->setDisplayConfigurable('form', TRUE);
$fields['trial_ends'] = BaseFieldDefinition::create('timestamp')
->setLabel(t('Trial ends'))
->setDescription(t('The time when the subscription trial ends.'))
->setRequired(FALSE)
->setDisplayOptions('view', [
'label' => 'hidden',
'type' => 'timestamp',
'weight' => 0,
])
->setDisplayOptions('form', [
'type' => 'commerce_recurring_end_timestamp',
'weight' => 0,
])
->setDisplayConfigurable('view', TRUE)
->setDisplayConfigurable('form', TRUE);
$fields['starts'] = BaseFieldDefinition::create('timestamp')
->setLabel(t('Starts'))
->setDescription(t('The time when the subscription starts.'))
->setRequired(TRUE)
->setDisplayOptions('view', [
'label' => 'hidden',
'type' => 'timestamp',
'weight' => 0,
])
->setDisplayConfigurable('view', TRUE)
->setDisplayOptions('form', [
'type' => 'datetime_timestamp',
'weight' => 0,
])
->setDisplayConfigurable('form', TRUE);
$fields['ends'] = BaseFieldDefinition::create('timestamp')
->setLabel(t('Ends'))
->setDescription(t('The time when the subscription ends.'))
->setRequired(FALSE)
->setDisplayOptions('view', [
'label' => 'hidden',
'type' => 'timestamp',
'weight' => 0,
])
->setDisplayConfigurable('view', TRUE)
->setDisplayOptions('form', [
'type' => 'commerce_recurring_end_timestamp',
'weight' => 0,
])
->setDisplayConfigurable('form', TRUE);
$fields['scheduled_changes'] = BaseFieldDefinition::create('commerce_scheduled_change')
->setLabel(t('Scheduled changes'))
->setRequired(FALSE)
->setCardinality(BaseFieldDefinition::CARDINALITY_UNLIMITED)
->setDisplayOptions('view', [
'label' => 'hidden',
'type' => 'commerce_scheduled_change_default',
'weight' => 0,
])
->setDisplayConfigurable('form', FALSE)
->setDisplayConfigurable('view', TRUE);
return $fields;
}
/**
* {@inheritdoc}
*/
public static function bundleFieldDefinitions(EntityTypeInterface $entity_type, $bundle, array $base_field_definitions) {
/** @var \Drupal\commerce_recurring\SubscriptionTypeManager $subscription_type_manager */
$subscription_type_manager = \Drupal::service('plugin.manager.commerce_subscription_type');
/** @var \Drupal\commerce_recurring\Plugin\Commerce\SubscriptionType\SubscriptionTypeInterface $subscription_type */
$subscription_type = $subscription_type_manager
->createInstance($bundle);
$fields = [
'purchased_entity' => clone $base_field_definitions['purchased_entity'],
];
$entity_type_id = $subscription_type
->getPurchasableEntityTypeId();
if ($entity_type_id) {
/** @var \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager */
$entity_type_manager = \Drupal::service('entity_type.manager');
/** @var \Drupal\Core\Entity\EntityTypeInterface $entity_type */
$entity_type = $entity_type_manager
->getDefinition($entity_type_id);
$fields['purchased_entity']
->setLabel($entity_type
->getLabel())
->setSetting('target_type', $entity_type_id);
}
else {
// This subscription type doesn't reference a purchasable entity. The field
// can't be removed here, or converted to a configurable one, so it's
// hidden instead. https://www.drupal.org/node/2346347#comment-10254087.
$fields['purchased_entity']
->setRequired(FALSE)
->setDisplayOptions('form', [
'region' => 'hidden',
])
->setDisplayConfigurable('form', FALSE)
->setDisplayConfigurable('view', FALSE)
->setReadOnly(TRUE);
}
return $fields;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CacheableDependencyTrait:: |
protected | property | Cache contexts. | |
CacheableDependencyTrait:: |
protected | property | Cache max-age. | |
CacheableDependencyTrait:: |
protected | property | Cache tags. | |
CacheableDependencyTrait:: |
protected | function | Sets cacheability; useful for value object constructors. | |
ContentEntityBase:: |
protected | property | Language code identifying the entity active language. | |
ContentEntityBase:: |
protected | property | Local cache for the default language code. | |
ContentEntityBase:: |
protected | property | The default langcode entity key. | |
ContentEntityBase:: |
protected | property | Whether the revision translation affected flag has been enforced. | |
ContentEntityBase:: |
protected | property | Holds untranslatable entity keys such as the ID, bundle, and revision ID. | |
ContentEntityBase:: |
protected | property | Local cache for field definitions. | |
ContentEntityBase:: |
protected | property | The array of fields, each being an instance of FieldItemListInterface. | |
ContentEntityBase:: |
protected static | property | Local cache for fields to skip from the checking for translation changes. | |
ContentEntityBase:: |
protected | property | Indicates whether this is the default revision. | |
ContentEntityBase:: |
protected | property | The language entity key. | |
ContentEntityBase:: |
protected | property | Local cache for the available language objects. | |
ContentEntityBase:: |
protected | property | The loaded revision ID before the new revision was set. | |
ContentEntityBase:: |
protected | property | Boolean indicating whether a new revision should be created on save. | |
ContentEntityBase:: |
protected | property | The revision translation affected entity key. | |
ContentEntityBase:: |
protected | property | Holds translatable entity keys such as the label. | |
ContentEntityBase:: |
protected | property | A flag indicating whether a translation object is being initialized. | |
ContentEntityBase:: |
protected | property | An array of entity translation metadata. | |
ContentEntityBase:: |
protected | property | Whether entity validation was performed. | |
ContentEntityBase:: |
protected | property | Whether entity validation is required before saving the entity. | |
ContentEntityBase:: |
protected | property | The plain data values of the contained fields. | |
ContentEntityBase:: |
public | function |
Checks data value access. Overrides EntityBase:: |
1 |
ContentEntityBase:: |
public | function |
Adds a new translation to the translatable object. Overrides TranslatableInterface:: |
|
ContentEntityBase:: |
public | function |
Gets the bundle of the entity. Overrides EntityBase:: |
|
ContentEntityBase:: |
protected | function | Clear entity translation object cache to remove stale references. | |
ContentEntityBase:: |
public | function |
Creates a duplicate of the entity. Overrides EntityBase:: |
1 |
ContentEntityBase:: |
public | function |
Gets a field item list. Overrides FieldableEntityInterface:: |
|
ContentEntityBase:: |
protected | function | Gets the value of the given entity key, if defined. | 1 |
ContentEntityBase:: |
public | function |
Gets the definition of a contained field. Overrides FieldableEntityInterface:: |
|
ContentEntityBase:: |
public | function |
Gets an array of field definitions of all contained fields. Overrides FieldableEntityInterface:: |
|
ContentEntityBase:: |
public | function |
Gets an array of all field item lists. Overrides FieldableEntityInterface:: |
|
ContentEntityBase:: |
protected | function | Returns an array of field names to skip in ::hasTranslationChanges. | 1 |
ContentEntityBase:: |
public | function | ||
ContentEntityBase:: |
protected | function | ||
ContentEntityBase:: |
public | function |
Gets the loaded Revision ID of the entity. Overrides RevisionableInterface:: |
|
ContentEntityBase:: |
public | function |
Gets the revision identifier of the entity. Overrides RevisionableInterface:: |
|
ContentEntityBase:: |
public | function |
Gets an array of field item lists for translatable fields. Overrides FieldableEntityInterface:: |
|
ContentEntityBase:: |
protected | function | Gets a translated field. | |
ContentEntityBase:: |
public | function |
Gets a translation of the data. Overrides TranslatableInterface:: |
|
ContentEntityBase:: |
public | function |
Returns the languages the data is translated to. Overrides TranslatableInterface:: |
|
ContentEntityBase:: |
public | function |
Returns the translation status. Overrides TranslationStatusInterface:: |
|
ContentEntityBase:: |
public | function |
Returns the translatable object referring to the original language. Overrides TranslatableInterface:: |
|
ContentEntityBase:: |
public | function |
Determines whether the entity has a field with the given name. Overrides FieldableEntityInterface:: |
|
ContentEntityBase:: |
public | function |
Checks there is a translation for the given language code. Overrides TranslatableInterface:: |
|
ContentEntityBase:: |
public | function |
Determines if the current translation of the entity has unsaved changes. Overrides TranslatableInterface:: |
|
ContentEntityBase:: |
public | function |
Gets the identifier. Overrides EntityBase:: |
|
ContentEntityBase:: |
protected | function | Instantiates a translation object for an existing translation. | |
ContentEntityBase:: |
public | function |
Checks if this entity is the default revision. Overrides RevisionableInterface:: |
|
ContentEntityBase:: |
public | function |
Checks whether the translation is the default one. Overrides TranslatableInterface:: |
|
ContentEntityBase:: |
public | function |
Checks if untranslatable fields should affect only the default translation. Overrides TranslatableRevisionableInterface:: |
|
ContentEntityBase:: |
public | function |
Checks if this entity is the latest revision. Overrides RevisionableInterface:: |
|
ContentEntityBase:: |
public | function |
Checks whether this is the latest revision affecting this translation. Overrides TranslatableRevisionableInterface:: |
|
ContentEntityBase:: |
public | function |
Determines whether a new revision should be created on save. Overrides RevisionableInterface:: |
|
ContentEntityBase:: |
public | function |
Checks whether the translation is new. Overrides TranslatableInterface:: |
|
ContentEntityBase:: |
public | function |
Checks whether the current translation is affected by the current revision. Overrides TranslatableRevisionableInterface:: |
|
ContentEntityBase:: |
public | function |
Checks if the revision translation affected flag value has been enforced. Overrides TranslatableRevisionableInterface:: |
|
ContentEntityBase:: |
public | function |
Returns the translation support status. Overrides TranslatableInterface:: |
|
ContentEntityBase:: |
public | function |
Checks whether entity validation is required before saving the entity. Overrides FieldableEntityInterface:: |
|
ContentEntityBase:: |
public | function |
Gets the language of the entity. Overrides EntityBase:: |
|
ContentEntityBase:: |
public | function |
Reacts to changes to a field. Overrides FieldableEntityInterface:: |
|
ContentEntityBase:: |
public | function |
Acts on a created entity before hooks are invoked. Overrides EntityBase:: |
|
ContentEntityBase:: |
public | function |
Acts on a revision before it gets saved. Overrides RevisionableInterface:: |
2 |
ContentEntityBase:: |
public | function |
Gets a list of entities referenced by this entity. Overrides EntityBase:: |
1 |
ContentEntityBase:: |
public | function |
Removes the translation identified by the given language code. Overrides TranslatableInterface:: |
|
ContentEntityBase:: |
public | function |
Sets a field value. Overrides FieldableEntityInterface:: |
|
ContentEntityBase:: |
protected | function | Populates the local cache for the default language code. | |
ContentEntityBase:: |
public | function |
Enforces an entity to be saved as a new revision. Overrides RevisionableInterface:: |
|
ContentEntityBase:: |
public | function |
Marks the current revision translation as affected. Overrides TranslatableRevisionableInterface:: |
|
ContentEntityBase:: |
public | function |
Enforces the revision translation affected flag value. Overrides TranslatableRevisionableInterface:: |
|
ContentEntityBase:: |
public | function |
Sets whether entity validation is required before saving the entity. Overrides FieldableEntityInterface:: |
|
ContentEntityBase:: |
public | function |
Gets an array of all property values. Overrides EntityBase:: |
|
ContentEntityBase:: |
protected | function | Updates language for already instantiated fields. | |
ContentEntityBase:: |
public | function |
Updates the loaded Revision ID with the revision ID. Overrides RevisionableInterface:: |
|
ContentEntityBase:: |
public | function | Updates the original values with the interim changes. | |
ContentEntityBase:: |
public | function |
Gets the entity UUID (Universally Unique Identifier). Overrides EntityBase:: |
|
ContentEntityBase:: |
public | function |
Validates the currently set values. Overrides FieldableEntityInterface:: |
|
ContentEntityBase:: |
public | function |
Checks whether the entity object was a default revision when it was saved. Overrides RevisionableInterface:: |
|
ContentEntityBase:: |
public | function | Magic method: Implements a deep clone. | |
ContentEntityBase:: |
public | function |
Constructs an Entity object. Overrides EntityBase:: |
|
ContentEntityBase:: |
public | function | Implements the magic method for getting object properties. | |
ContentEntityBase:: |
public | function | Implements the magic method for isset(). | |
ContentEntityBase:: |
public | function | Implements the magic method for setting object properties. | |
ContentEntityBase:: |
public | function |
Overrides EntityBase:: |
|
ContentEntityBase:: |
public | function | Implements the magic method for unset(). | |
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | Aliased as: traitSleep | 1 |
DependencySerializationTrait:: |
public | function | 2 | |
EntityBase:: |
protected | property | Boolean indicating whether the entity should be forced to be new. | |
EntityBase:: |
protected | property | The entity type. | |
EntityBase:: |
protected | property | A typed data object wrapping this entity. | |
EntityBase:: |
public static | function |
Constructs a new entity object, without permanently saving it. Overrides EntityInterface:: |
|
EntityBase:: |
public | function |
Deletes an entity permanently. Overrides EntityInterface:: |
2 |
EntityBase:: |
public | function |
Enforces an entity to be new. Overrides EntityInterface:: |
|
EntityBase:: |
protected | function | Gets the entity manager. | |
EntityBase:: |
protected | function | Gets the entity type bundle info service. | |
EntityBase:: |
protected | function | Gets the entity type manager. | |
EntityBase:: |
public | function |
The cache contexts associated with this object. Overrides CacheableDependencyTrait:: |
|
EntityBase:: |
public | function |
The maximum age for which this object may be cached. Overrides CacheableDependencyTrait:: |
|
EntityBase:: |
public | function |
The cache tags associated with this object. Overrides CacheableDependencyTrait:: |
|
EntityBase:: |
public | function |
Returns the cache tags that should be used to invalidate caches. Overrides EntityInterface:: |
2 |
EntityBase:: |
public | function |
Gets the key that is used to store configuration dependencies. Overrides EntityInterface:: |
|
EntityBase:: |
public | function |
Gets the configuration dependency name. Overrides EntityInterface:: |
1 |
EntityBase:: |
public | function |
Gets the configuration target identifier for the entity. Overrides EntityInterface:: |
1 |
EntityBase:: |
public | function |
Gets the entity type definition. Overrides EntityInterface:: |
|
EntityBase:: |
public | function |
Gets the ID of the type of the entity. Overrides EntityInterface:: |
|
EntityBase:: |
protected | function | The list cache tags to invalidate for this entity. | |
EntityBase:: |
public | function |
Gets the original ID. Overrides EntityInterface:: |
1 |
EntityBase:: |
public | function |
Gets a typed data object for this entity object. Overrides EntityInterface:: |
|
EntityBase:: |
public | function |
Indicates if a link template exists for a given key. Overrides EntityInterface:: |
|
EntityBase:: |
protected static | function | Invalidates an entity's cache tags upon delete. | 1 |
EntityBase:: |
protected | function | Invalidates an entity's cache tags upon save. | 1 |
EntityBase:: |
public | function |
Determines whether the entity is new. Overrides EntityInterface:: |
2 |
EntityBase:: |
protected | function | Gets the language manager. | |
EntityBase:: |
public | function |
Deprecated way of generating a link to the entity. See toLink(). Overrides EntityInterface:: |
1 |
EntityBase:: |
protected | function | Gets an array link templates. | 1 |
EntityBase:: |
public static | function |
Loads an entity. Overrides EntityInterface:: |
|
EntityBase:: |
public static | function |
Loads one or more entities. Overrides EntityInterface:: |
|
EntityBase:: |
public static | function |
Acts on loaded entities. Overrides EntityInterface:: |
2 |
EntityBase:: |
public static | function |
Changes the values of an entity before it is created. Overrides EntityInterface:: |
5 |
EntityBase:: |
public static | function |
Acts on entities before they are deleted and before hooks are invoked. Overrides EntityInterface:: |
4 |
EntityBase:: |
public | function |
Saves an entity permanently. Overrides EntityInterface:: |
3 |
EntityBase:: |
public | function |
Sets the original ID. Overrides EntityInterface:: |
1 |
EntityBase:: |
public | function |
Generates the HTML for a link to this entity. Overrides EntityInterface:: |
|
EntityBase:: |
public | function |
Gets the URL object for the entity. Overrides EntityInterface:: |
2 |
EntityBase:: |
public | function |
Gets a list of URI relationships supported by this entity. Overrides EntityInterface:: |
|
EntityBase:: |
public | function |
Gets the public URL for this entity. Overrides EntityInterface:: |
2 |
EntityBase:: |
public | function |
Gets the URL object for the entity. Overrides EntityInterface:: |
1 |
EntityBase:: |
protected | function | Gets the UUID generator. | |
EntityChangesDetectionTrait:: |
protected | function | Returns an array of field names to skip when checking for changes. Aliased as: traitGetFieldsToSkipFromTranslationChangesCheck | |
EntityOwnerTrait:: |
public static | function | Default value callback for 'owner' base field. | 1 |
EntityOwnerTrait:: |
public | function |
Overrides EntityOwnerTrait:: |
|
EntityOwnerTrait:: |
public | function | ||
EntityOwnerTrait:: |
public static | function | Returns an array of base field definitions for entity owners. | |
EntityOwnerTrait:: |
public | function | ||
EntityOwnerTrait:: |
public | function | ||
RefinableCacheableDependencyTrait:: |
public | function | 1 | |
RefinableCacheableDependencyTrait:: |
public | function | ||
RefinableCacheableDependencyTrait:: |
public | function | ||
RefinableCacheableDependencyTrait:: |
public | function | ||
Subscription:: |
public | function |
Adds a recurring order. Overrides SubscriptionInterface:: |
|
Subscription:: |
public | function |
Adds a scheduled change for the given field. Overrides SubscriptionInterface:: |
|
Subscription:: |
public | function |
Apply the scheduled changes. Overrides SubscriptionInterface:: |
|
Subscription:: |
public static | function |
Provides base field definitions for an entity type. Overrides ContentEntityBase:: |
|
Subscription:: |
public static | function |
Provides field definitions for a specific bundle. Overrides ContentEntityBase:: |
|
Subscription:: |
public | function |
Cancel the subscription. Overrides SubscriptionInterface:: |
|
Subscription:: |
public | function |
Gets the billing schedule. Overrides SubscriptionInterface:: |
|
Subscription:: |
public | function |
Gets the created timestamp. Overrides SubscriptionInterface:: |
|
Subscription:: |
public | function |
Gets the billing period value object for the current order. Overrides SubscriptionInterface:: |
|
Subscription:: |
public | function |
Gets the current draft recurring order. Overrides SubscriptionInterface:: |
|
Subscription:: |
public | function |
Gets the customer. Overrides SubscriptionInterface:: |
|
Subscription:: |
public | function |
Gets the customer ID. Overrides SubscriptionInterface:: |
|
Subscription:: |
public | function |
Gets the end timestamp as a DrupalDateTime object. Overrides SubscriptionInterface:: |
|
Subscription:: |
public | function |
Gets the end timestamp. Overrides SubscriptionInterface:: |
|
Subscription:: |
public | function |
Gets the initial order. Overrides SubscriptionInterface:: |
|
Subscription:: |
public | function |
Gets the initial order ID. Overrides SubscriptionInterface:: |
|
Subscription:: |
public | function |
Gets the next renewal timestamp as a DrupalDateTime object. Overrides SubscriptionInterface:: |
|
Subscription:: |
public | function |
Gets the next renewal timestamp. Overrides SubscriptionInterface:: |
|
Subscription:: |
public | function |
Gets the recurring order IDs. Overrides SubscriptionInterface:: |
|
Subscription:: |
protected | function | Gets the index of the given recurring order. | |
Subscription:: |
public | function |
Gets the recurring orders. Overrides SubscriptionInterface:: |
|
Subscription:: |
public | function |
Gets the payment method. Overrides SubscriptionInterface:: |
|
Subscription:: |
public | function |
Gets the payment method ID. Overrides SubscriptionInterface:: |
|
Subscription:: |
public | function |
Gets the purchased entity. Overrides SubscriptionInterface:: |
|
Subscription:: |
public | function |
Gets the purchased entity ID. Overrides SubscriptionInterface:: |
|
Subscription:: |
public | function |
Gets the subscription quantity. Overrides SubscriptionInterface:: |
|
Subscription:: |
public | function |
Gets the renewal timestamp. Overrides SubscriptionInterface:: |
|
Subscription:: |
public | function |
Gets the scheduled changes. Overrides SubscriptionInterface:: |
|
Subscription:: |
public | function |
Gets the start timestamp as a DrupalDateTime object. Overrides SubscriptionInterface:: |
|
Subscription:: |
public | function |
Gets the start timestamp. Overrides SubscriptionInterface:: |
|
Subscription:: |
public | function |
Gets the subscription state. Overrides SubscriptionInterface:: |
|
Subscription:: |
public | function |
Gets the store. Overrides SubscriptionInterface:: |
|
Subscription:: |
public | function |
Gets the store ID. Overrides SubscriptionInterface:: |
|
Subscription:: |
public | function |
Gets the subscription title. Overrides SubscriptionInterface:: |
|
Subscription:: |
public | function |
Gets the trial end timestamp as a DrupalDateTime object. Overrides SubscriptionInterface:: |
|
Subscription:: |
public | function |
Gets the trial end timestamp. Overrides SubscriptionInterface:: |
|
Subscription:: |
public | function |
Gets the trial start timestamp as a DrupalDateTime object. Overrides SubscriptionInterface:: |
|
Subscription:: |
public | function |
Gets the trial start timestamp. Overrides SubscriptionInterface:: |
|
Subscription:: |
public | function |
Gets the subscription type. Overrides SubscriptionInterface:: |
|
Subscription:: |
public | function |
Gets the subscription unit price. Overrides SubscriptionInterface:: |
|
Subscription:: |
public | function |
Checks whether the order has a given recurring order. Overrides SubscriptionInterface:: |
|
Subscription:: |
public | function |
Gets whether the subscription has a purchased entity. Overrides SubscriptionInterface:: |
|
Subscription:: |
public | function |
Determines if a scheduled change for the given field exists. Overrides SubscriptionInterface:: |
|
Subscription:: |
public | function |
Gets whether the subscription has scheduled changes. Overrides SubscriptionInterface:: |
|
Subscription:: |
public | function |
Gets the label of the entity. Overrides ContentEntityBase:: |
|
Subscription:: |
public static | function |
Acts on deleted entities before the delete hook is invoked. Overrides EntityBase:: |
|
Subscription:: |
public | function |
Acts on a saved entity before the insert or update hook is invoked. Overrides ContentEntityBase:: |
|
Subscription:: |
public | function |
Acts on an entity before the presave hook is invoked. Overrides ContentEntityBase:: |
|
Subscription:: |
public | function |
Removes a recurring order. Overrides SubscriptionInterface:: |
|
Subscription:: |
public | function |
Removes the scheduled changes. Overrides SubscriptionInterface:: |
|
Subscription:: |
public | function |
Sets the billing schedule. Overrides SubscriptionInterface:: |
|
Subscription:: |
public | function |
Sets the created timestamp. Overrides SubscriptionInterface:: |
|
Subscription:: |
public | function |
Sets the customer. Overrides SubscriptionInterface:: |
|
Subscription:: |
public | function |
Sets the customer ID. Overrides SubscriptionInterface:: |
|
Subscription:: |
public | function |
Sets the end timestamp. Overrides SubscriptionInterface:: |
|
Subscription:: |
public | function |
Sets the initial order. Overrides SubscriptionInterface:: |
|
Subscription:: |
public | function |
Sets the next renewal timestamp. Overrides SubscriptionInterface:: |
|
Subscription:: |
public | function |
Sets the recurring orders. Overrides SubscriptionInterface:: |
|
Subscription:: |
public | function |
Sets the payment method. Overrides SubscriptionInterface:: |
|
Subscription:: |
public | function |
Sets the payment method ID. Overrides SubscriptionInterface:: |
|
Subscription:: |
public | function |
Sets the purchased entity. Overrides SubscriptionInterface:: |
|
Subscription:: |
public | function |
Sets the subscription quantity. Overrides SubscriptionInterface:: |
|
Subscription:: |
public | function |
Sets the renewal timestamp. Overrides SubscriptionInterface:: |
|
Subscription:: |
public | function |
Sets the scheduled changes. Overrides SubscriptionInterface:: |
|
Subscription:: |
public | function |
Sets the start timestamp. Overrides SubscriptionInterface:: |
|
Subscription:: |
public | function |
Sets the subscription state. Overrides SubscriptionInterface:: |
|
Subscription:: |
public | function |
Sets the subscription title. Overrides SubscriptionInterface:: |
|
Subscription:: |
public | function |
Sets the trial end timestamp. Overrides SubscriptionInterface:: |
|
Subscription:: |
public | function |
Sets the trial start timestamp. Overrides SubscriptionInterface:: |
|
Subscription:: |
public | function |
Sets the subscription unit price. Overrides SubscriptionInterface:: |
|
Subscription:: |
protected | function |
Gets an array of placeholders for this entity. Overrides EntityBase:: |
|
SynchronizableEntityTrait:: |
protected | property | Whether this entity is being created, updated or deleted through a synchronization process. | |
SynchronizableEntityTrait:: |
public | function | ||
SynchronizableEntityTrait:: |
public | function | ||
TranslationStatusInterface:: |
constant | Status code identifying a newly created translation. | ||
TranslationStatusInterface:: |
constant | Status code identifying an existing translation. | ||
TranslationStatusInterface:: |
constant | Status code identifying a removed translation. |