You are here

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

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

... See full list

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

... See full list

File

src/Entity/Subscription.php, line 77

Namespace

Drupal\commerce_recurring\Entity
View 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

Namesort descending Modifiers Type Description Overrides
CacheableDependencyTrait::$cacheContexts protected property Cache contexts.
CacheableDependencyTrait::$cacheMaxAge protected property Cache max-age.
CacheableDependencyTrait::$cacheTags protected property Cache tags.
CacheableDependencyTrait::setCacheability protected function Sets cacheability; useful for value object constructors.
ContentEntityBase::$activeLangcode protected property Language code identifying the entity active language.
ContentEntityBase::$defaultLangcode protected property Local cache for the default language code.
ContentEntityBase::$defaultLangcodeKey protected property The default langcode entity key.
ContentEntityBase::$enforceRevisionTranslationAffected protected property Whether the revision translation affected flag has been enforced.
ContentEntityBase::$entityKeys protected property Holds untranslatable entity keys such as the ID, bundle, and revision ID.
ContentEntityBase::$fieldDefinitions protected property Local cache for field definitions.
ContentEntityBase::$fields protected property The array of fields, each being an instance of FieldItemListInterface.
ContentEntityBase::$fieldsToSkipFromTranslationChangesCheck protected static property Local cache for fields to skip from the checking for translation changes.
ContentEntityBase::$isDefaultRevision protected property Indicates whether this is the default revision.
ContentEntityBase::$langcodeKey protected property The language entity key.
ContentEntityBase::$languages protected property Local cache for the available language objects.
ContentEntityBase::$loadedRevisionId protected property The loaded revision ID before the new revision was set.
ContentEntityBase::$newRevision protected property Boolean indicating whether a new revision should be created on save.
ContentEntityBase::$revisionTranslationAffectedKey protected property The revision translation affected entity key.
ContentEntityBase::$translatableEntityKeys protected property Holds translatable entity keys such as the label.
ContentEntityBase::$translationInitialize protected property A flag indicating whether a translation object is being initialized.
ContentEntityBase::$translations protected property An array of entity translation metadata.
ContentEntityBase::$validated protected property Whether entity validation was performed.
ContentEntityBase::$validationRequired protected property Whether entity validation is required before saving the entity.
ContentEntityBase::$values protected property The plain data values of the contained fields.
ContentEntityBase::access public function Checks data value access. Overrides EntityBase::access 1
ContentEntityBase::addTranslation public function Adds a new translation to the translatable object. Overrides TranslatableInterface::addTranslation
ContentEntityBase::bundle public function Gets the bundle of the entity. Overrides EntityBase::bundle
ContentEntityBase::clearTranslationCache protected function Clear entity translation object cache to remove stale references.
ContentEntityBase::createDuplicate public function Creates a duplicate of the entity. Overrides EntityBase::createDuplicate 1
ContentEntityBase::get public function Gets a field item list. Overrides FieldableEntityInterface::get
ContentEntityBase::getEntityKey protected function Gets the value of the given entity key, if defined. 1
ContentEntityBase::getFieldDefinition public function Gets the definition of a contained field. Overrides FieldableEntityInterface::getFieldDefinition
ContentEntityBase::getFieldDefinitions public function Gets an array of field definitions of all contained fields. Overrides FieldableEntityInterface::getFieldDefinitions
ContentEntityBase::getFields public function Gets an array of all field item lists. Overrides FieldableEntityInterface::getFields
ContentEntityBase::getFieldsToSkipFromTranslationChangesCheck protected function Returns an array of field names to skip in ::hasTranslationChanges. 1
ContentEntityBase::getIterator public function
ContentEntityBase::getLanguages protected function
ContentEntityBase::getLoadedRevisionId public function Gets the loaded Revision ID of the entity. Overrides RevisionableInterface::getLoadedRevisionId
ContentEntityBase::getRevisionId public function Gets the revision identifier of the entity. Overrides RevisionableInterface::getRevisionId
ContentEntityBase::getTranslatableFields public function Gets an array of field item lists for translatable fields. Overrides FieldableEntityInterface::getTranslatableFields
ContentEntityBase::getTranslatedField protected function Gets a translated field.
ContentEntityBase::getTranslation public function Gets a translation of the data. Overrides TranslatableInterface::getTranslation
ContentEntityBase::getTranslationLanguages public function Returns the languages the data is translated to. Overrides TranslatableInterface::getTranslationLanguages
ContentEntityBase::getTranslationStatus public function Returns the translation status. Overrides TranslationStatusInterface::getTranslationStatus
ContentEntityBase::getUntranslated public function Returns the translatable object referring to the original language. Overrides TranslatableInterface::getUntranslated
ContentEntityBase::hasField public function Determines whether the entity has a field with the given name. Overrides FieldableEntityInterface::hasField
ContentEntityBase::hasTranslation public function Checks there is a translation for the given language code. Overrides TranslatableInterface::hasTranslation
ContentEntityBase::hasTranslationChanges public function Determines if the current translation of the entity has unsaved changes. Overrides TranslatableInterface::hasTranslationChanges
ContentEntityBase::id public function Gets the identifier. Overrides EntityBase::id
ContentEntityBase::initializeTranslation protected function Instantiates a translation object for an existing translation.
ContentEntityBase::isDefaultRevision public function Checks if this entity is the default revision. Overrides RevisionableInterface::isDefaultRevision
ContentEntityBase::isDefaultTranslation public function Checks whether the translation is the default one. Overrides TranslatableInterface::isDefaultTranslation
ContentEntityBase::isDefaultTranslationAffectedOnly public function Checks if untranslatable fields should affect only the default translation. Overrides TranslatableRevisionableInterface::isDefaultTranslationAffectedOnly
ContentEntityBase::isLatestRevision public function Checks if this entity is the latest revision. Overrides RevisionableInterface::isLatestRevision
ContentEntityBase::isLatestTranslationAffectedRevision public function Checks whether this is the latest revision affecting this translation. Overrides TranslatableRevisionableInterface::isLatestTranslationAffectedRevision
ContentEntityBase::isNewRevision public function Determines whether a new revision should be created on save. Overrides RevisionableInterface::isNewRevision
ContentEntityBase::isNewTranslation public function Checks whether the translation is new. Overrides TranslatableInterface::isNewTranslation
ContentEntityBase::isRevisionTranslationAffected public function Checks whether the current translation is affected by the current revision. Overrides TranslatableRevisionableInterface::isRevisionTranslationAffected
ContentEntityBase::isRevisionTranslationAffectedEnforced public function Checks if the revision translation affected flag value has been enforced. Overrides TranslatableRevisionableInterface::isRevisionTranslationAffectedEnforced
ContentEntityBase::isTranslatable public function Returns the translation support status. Overrides TranslatableInterface::isTranslatable
ContentEntityBase::isValidationRequired public function Checks whether entity validation is required before saving the entity. Overrides FieldableEntityInterface::isValidationRequired
ContentEntityBase::language public function Gets the language of the entity. Overrides EntityBase::language
ContentEntityBase::onChange public function Reacts to changes to a field. Overrides FieldableEntityInterface::onChange
ContentEntityBase::postCreate public function Acts on a created entity before hooks are invoked. Overrides EntityBase::postCreate
ContentEntityBase::preSaveRevision public function Acts on a revision before it gets saved. Overrides RevisionableInterface::preSaveRevision 2
ContentEntityBase::referencedEntities public function Gets a list of entities referenced by this entity. Overrides EntityBase::referencedEntities 1
ContentEntityBase::removeTranslation public function Removes the translation identified by the given language code. Overrides TranslatableInterface::removeTranslation
ContentEntityBase::set public function Sets a field value. Overrides FieldableEntityInterface::set
ContentEntityBase::setDefaultLangcode protected function Populates the local cache for the default language code.
ContentEntityBase::setNewRevision public function Enforces an entity to be saved as a new revision. Overrides RevisionableInterface::setNewRevision
ContentEntityBase::setRevisionTranslationAffected public function Marks the current revision translation as affected. Overrides TranslatableRevisionableInterface::setRevisionTranslationAffected
ContentEntityBase::setRevisionTranslationAffectedEnforced public function Enforces the revision translation affected flag value. Overrides TranslatableRevisionableInterface::setRevisionTranslationAffectedEnforced
ContentEntityBase::setValidationRequired public function Sets whether entity validation is required before saving the entity. Overrides FieldableEntityInterface::setValidationRequired
ContentEntityBase::toArray public function Gets an array of all property values. Overrides EntityBase::toArray
ContentEntityBase::updateFieldLangcodes protected function Updates language for already instantiated fields.
ContentEntityBase::updateLoadedRevisionId public function Updates the loaded Revision ID with the revision ID. Overrides RevisionableInterface::updateLoadedRevisionId
ContentEntityBase::updateOriginalValues public function Updates the original values with the interim changes.
ContentEntityBase::uuid public function Gets the entity UUID (Universally Unique Identifier). Overrides EntityBase::uuid
ContentEntityBase::validate public function Validates the currently set values. Overrides FieldableEntityInterface::validate
ContentEntityBase::wasDefaultRevision public function Checks whether the entity object was a default revision when it was saved. Overrides RevisionableInterface::wasDefaultRevision
ContentEntityBase::__clone public function Magic method: Implements a deep clone.
ContentEntityBase::__construct public function Constructs an Entity object. Overrides EntityBase::__construct
ContentEntityBase::__get public function Implements the magic method for getting object properties.
ContentEntityBase::__isset public function Implements the magic method for isset().
ContentEntityBase::__set public function Implements the magic method for setting object properties.
ContentEntityBase::__sleep public function Overrides EntityBase::__sleep
ContentEntityBase::__unset public function Implements the magic method for unset().
DependencySerializationTrait::$_entityStorages protected property An array of entity type IDs keyed by the property name of their storages.
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function Aliased as: traitSleep 1
DependencySerializationTrait::__wakeup public function 2
EntityBase::$enforceIsNew protected property Boolean indicating whether the entity should be forced to be new.
EntityBase::$entityTypeId protected property The entity type.
EntityBase::$typedData protected property A typed data object wrapping this entity.
EntityBase::create public static function Constructs a new entity object, without permanently saving it. Overrides EntityInterface::create
EntityBase::delete public function Deletes an entity permanently. Overrides EntityInterface::delete 2
EntityBase::enforceIsNew public function Enforces an entity to be new. Overrides EntityInterface::enforceIsNew
EntityBase::entityManager Deprecated protected function Gets the entity manager.
EntityBase::entityTypeBundleInfo protected function Gets the entity type bundle info service.
EntityBase::entityTypeManager protected function Gets the entity type manager.
EntityBase::getCacheContexts public function The cache contexts associated with this object. Overrides CacheableDependencyTrait::getCacheContexts
EntityBase::getCacheMaxAge public function The maximum age for which this object may be cached. Overrides CacheableDependencyTrait::getCacheMaxAge
EntityBase::getCacheTags public function The cache tags associated with this object. Overrides CacheableDependencyTrait::getCacheTags
EntityBase::getCacheTagsToInvalidate public function Returns the cache tags that should be used to invalidate caches. Overrides EntityInterface::getCacheTagsToInvalidate 2
EntityBase::getConfigDependencyKey public function Gets the key that is used to store configuration dependencies. Overrides EntityInterface::getConfigDependencyKey
EntityBase::getConfigDependencyName public function Gets the configuration dependency name. Overrides EntityInterface::getConfigDependencyName 1
EntityBase::getConfigTarget public function Gets the configuration target identifier for the entity. Overrides EntityInterface::getConfigTarget 1
EntityBase::getEntityType public function Gets the entity type definition. Overrides EntityInterface::getEntityType
EntityBase::getEntityTypeId public function Gets the ID of the type of the entity. Overrides EntityInterface::getEntityTypeId
EntityBase::getListCacheTagsToInvalidate protected function The list cache tags to invalidate for this entity.
EntityBase::getOriginalId public function Gets the original ID. Overrides EntityInterface::getOriginalId 1
EntityBase::getTypedData public function Gets a typed data object for this entity object. Overrides EntityInterface::getTypedData
EntityBase::hasLinkTemplate public function Indicates if a link template exists for a given key. Overrides EntityInterface::hasLinkTemplate
EntityBase::invalidateTagsOnDelete protected static function Invalidates an entity's cache tags upon delete. 1
EntityBase::invalidateTagsOnSave protected function Invalidates an entity's cache tags upon save. 1
EntityBase::isNew public function Determines whether the entity is new. Overrides EntityInterface::isNew 2
EntityBase::languageManager protected function Gets the language manager.
EntityBase::link public function Deprecated way of generating a link to the entity. See toLink(). Overrides EntityInterface::link 1
EntityBase::linkTemplates protected function Gets an array link templates. 1
EntityBase::load public static function Loads an entity. Overrides EntityInterface::load
EntityBase::loadMultiple public static function Loads one or more entities. Overrides EntityInterface::loadMultiple
EntityBase::postLoad public static function Acts on loaded entities. Overrides EntityInterface::postLoad 2
EntityBase::preCreate public static function Changes the values of an entity before it is created. Overrides EntityInterface::preCreate 5
EntityBase::preDelete public static function Acts on entities before they are deleted and before hooks are invoked. Overrides EntityInterface::preDelete 4
EntityBase::save public function Saves an entity permanently. Overrides EntityInterface::save 3
EntityBase::setOriginalId public function Sets the original ID. Overrides EntityInterface::setOriginalId 1
EntityBase::toLink public function Generates the HTML for a link to this entity. Overrides EntityInterface::toLink
EntityBase::toUrl public function Gets the URL object for the entity. Overrides EntityInterface::toUrl 2
EntityBase::uriRelationships public function Gets a list of URI relationships supported by this entity. Overrides EntityInterface::uriRelationships
EntityBase::url public function Gets the public URL for this entity. Overrides EntityInterface::url 2
EntityBase::urlInfo public function Gets the URL object for the entity. Overrides EntityInterface::urlInfo 1
EntityBase::uuidGenerator protected function Gets the UUID generator.
EntityChangesDetectionTrait::getFieldsToSkipFromTranslationChangesCheck protected function Returns an array of field names to skip when checking for changes. Aliased as: traitGetFieldsToSkipFromTranslationChangesCheck
EntityOwnerTrait::getDefaultEntityOwner public static function Default value callback for 'owner' base field. 1
EntityOwnerTrait::getOwner public function Overrides EntityOwnerTrait::getOwner
EntityOwnerTrait::getOwnerId public function
EntityOwnerTrait::ownerBaseFieldDefinitions public static function Returns an array of base field definitions for entity owners.
EntityOwnerTrait::setOwner public function
EntityOwnerTrait::setOwnerId public function
RefinableCacheableDependencyTrait::addCacheableDependency public function 1
RefinableCacheableDependencyTrait::addCacheContexts public function
RefinableCacheableDependencyTrait::addCacheTags public function
RefinableCacheableDependencyTrait::mergeCacheMaxAge public function
Subscription::addOrder public function Adds a recurring order. Overrides SubscriptionInterface::addOrder
Subscription::addScheduledChange public function Adds a scheduled change for the given field. Overrides SubscriptionInterface::addScheduledChange
Subscription::applyScheduledChanges public function Apply the scheduled changes. Overrides SubscriptionInterface::applyScheduledChanges
Subscription::baseFieldDefinitions public static function Provides base field definitions for an entity type. Overrides ContentEntityBase::baseFieldDefinitions
Subscription::bundleFieldDefinitions public static function Provides field definitions for a specific bundle. Overrides ContentEntityBase::bundleFieldDefinitions
Subscription::cancel public function Cancel the subscription. Overrides SubscriptionInterface::cancel
Subscription::getBillingSchedule public function Gets the billing schedule. Overrides SubscriptionInterface::getBillingSchedule
Subscription::getCreatedTime public function Gets the created timestamp. Overrides SubscriptionInterface::getCreatedTime
Subscription::getCurrentBillingPeriod public function Gets the billing period value object for the current order. Overrides SubscriptionInterface::getCurrentBillingPeriod
Subscription::getCurrentOrder public function Gets the current draft recurring order. Overrides SubscriptionInterface::getCurrentOrder
Subscription::getCustomer public function Gets the customer. Overrides SubscriptionInterface::getCustomer
Subscription::getCustomerId public function Gets the customer ID. Overrides SubscriptionInterface::getCustomerId
Subscription::getEndDate public function Gets the end timestamp as a DrupalDateTime object. Overrides SubscriptionInterface::getEndDate
Subscription::getEndTime public function Gets the end timestamp. Overrides SubscriptionInterface::getEndTime
Subscription::getInitialOrder public function Gets the initial order. Overrides SubscriptionInterface::getInitialOrder
Subscription::getInitialOrderId public function Gets the initial order ID. Overrides SubscriptionInterface::getInitialOrderId
Subscription::getNextRenewalDate public function Gets the next renewal timestamp as a DrupalDateTime object. Overrides SubscriptionInterface::getNextRenewalDate
Subscription::getNextRenewalTime public function Gets the next renewal timestamp. Overrides SubscriptionInterface::getNextRenewalTime
Subscription::getOrderIds public function Gets the recurring order IDs. Overrides SubscriptionInterface::getOrderIds
Subscription::getOrderIndex protected function Gets the index of the given recurring order.
Subscription::getOrders public function Gets the recurring orders. Overrides SubscriptionInterface::getOrders
Subscription::getPaymentMethod public function Gets the payment method. Overrides SubscriptionInterface::getPaymentMethod
Subscription::getPaymentMethodId public function Gets the payment method ID. Overrides SubscriptionInterface::getPaymentMethodId
Subscription::getPurchasedEntity public function Gets the purchased entity. Overrides SubscriptionInterface::getPurchasedEntity
Subscription::getPurchasedEntityId public function Gets the purchased entity ID. Overrides SubscriptionInterface::getPurchasedEntityId
Subscription::getQuantity public function Gets the subscription quantity. Overrides SubscriptionInterface::getQuantity
Subscription::getRenewedTime public function Gets the renewal timestamp. Overrides SubscriptionInterface::getRenewedTime
Subscription::getScheduledChanges public function Gets the scheduled changes. Overrides SubscriptionInterface::getScheduledChanges
Subscription::getStartDate public function Gets the start timestamp as a DrupalDateTime object. Overrides SubscriptionInterface::getStartDate
Subscription::getStartTime public function Gets the start timestamp. Overrides SubscriptionInterface::getStartTime
Subscription::getState public function Gets the subscription state. Overrides SubscriptionInterface::getState
Subscription::getStore public function Gets the store. Overrides SubscriptionInterface::getStore
Subscription::getStoreId public function Gets the store ID. Overrides SubscriptionInterface::getStoreId
Subscription::getTitle public function Gets the subscription title. Overrides SubscriptionInterface::getTitle
Subscription::getTrialEndDate public function Gets the trial end timestamp as a DrupalDateTime object. Overrides SubscriptionInterface::getTrialEndDate
Subscription::getTrialEndTime public function Gets the trial end timestamp. Overrides SubscriptionInterface::getTrialEndTime
Subscription::getTrialStartDate public function Gets the trial start timestamp as a DrupalDateTime object. Overrides SubscriptionInterface::getTrialStartDate
Subscription::getTrialStartTime public function Gets the trial start timestamp. Overrides SubscriptionInterface::getTrialStartTime
Subscription::getType public function Gets the subscription type. Overrides SubscriptionInterface::getType
Subscription::getUnitPrice public function Gets the subscription unit price. Overrides SubscriptionInterface::getUnitPrice
Subscription::hasOrder public function Checks whether the order has a given recurring order. Overrides SubscriptionInterface::hasOrder
Subscription::hasPurchasedEntity public function Gets whether the subscription has a purchased entity. Overrides SubscriptionInterface::hasPurchasedEntity
Subscription::hasScheduledChange public function Determines if a scheduled change for the given field exists. Overrides SubscriptionInterface::hasScheduledChange
Subscription::hasScheduledChanges public function Gets whether the subscription has scheduled changes. Overrides SubscriptionInterface::hasScheduledChanges
Subscription::label public function Gets the label of the entity. Overrides ContentEntityBase::label
Subscription::postDelete public static function Acts on deleted entities before the delete hook is invoked. Overrides EntityBase::postDelete
Subscription::postSave public function Acts on a saved entity before the insert or update hook is invoked. Overrides ContentEntityBase::postSave
Subscription::preSave public function Acts on an entity before the presave hook is invoked. Overrides ContentEntityBase::preSave
Subscription::removeOrder public function Removes a recurring order. Overrides SubscriptionInterface::removeOrder
Subscription::removeScheduledChanges public function Removes the scheduled changes. Overrides SubscriptionInterface::removeScheduledChanges
Subscription::setBillingSchedule public function Sets the billing schedule. Overrides SubscriptionInterface::setBillingSchedule
Subscription::setCreatedTime public function Sets the created timestamp. Overrides SubscriptionInterface::setCreatedTime
Subscription::setCustomer public function Sets the customer. Overrides SubscriptionInterface::setCustomer
Subscription::setCustomerId public function Sets the customer ID. Overrides SubscriptionInterface::setCustomerId
Subscription::setEndTime public function Sets the end timestamp. Overrides SubscriptionInterface::setEndTime
Subscription::setInitialOrder public function Sets the initial order. Overrides SubscriptionInterface::setInitialOrder
Subscription::setNextRenewalTime public function Sets the next renewal timestamp. Overrides SubscriptionInterface::setNextRenewalTime
Subscription::setOrders public function Sets the recurring orders. Overrides SubscriptionInterface::setOrders
Subscription::setPaymentMethod public function Sets the payment method. Overrides SubscriptionInterface::setPaymentMethod
Subscription::setPaymentMethodId public function Sets the payment method ID. Overrides SubscriptionInterface::setPaymentMethodId
Subscription::setPurchasedEntity public function Sets the purchased entity. Overrides SubscriptionInterface::setPurchasedEntity
Subscription::setQuantity public function Sets the subscription quantity. Overrides SubscriptionInterface::setQuantity
Subscription::setRenewedTime public function Sets the renewal timestamp. Overrides SubscriptionInterface::setRenewedTime
Subscription::setScheduledChanges public function Sets the scheduled changes. Overrides SubscriptionInterface::setScheduledChanges
Subscription::setStartTime public function Sets the start timestamp. Overrides SubscriptionInterface::setStartTime
Subscription::setState public function Sets the subscription state. Overrides SubscriptionInterface::setState
Subscription::setTitle public function Sets the subscription title. Overrides SubscriptionInterface::setTitle
Subscription::setTrialEndTime public function Sets the trial end timestamp. Overrides SubscriptionInterface::setTrialEndTime
Subscription::setTrialStartTime public function Sets the trial start timestamp. Overrides SubscriptionInterface::setTrialStartTime
Subscription::setUnitPrice public function Sets the subscription unit price. Overrides SubscriptionInterface::setUnitPrice
Subscription::urlRouteParameters protected function Gets an array of placeholders for this entity. Overrides EntityBase::urlRouteParameters
SynchronizableEntityTrait::$isSyncing protected property Whether this entity is being created, updated or deleted through a synchronization process.
SynchronizableEntityTrait::isSyncing public function
SynchronizableEntityTrait::setSyncing public function
TranslationStatusInterface::TRANSLATION_CREATED constant Status code identifying a newly created translation.
TranslationStatusInterface::TRANSLATION_EXISTING constant Status code identifying an existing translation.
TranslationStatusInterface::TRANSLATION_REMOVED constant Status code identifying a removed translation.