You are here

class CommerceCondition in Commerce Core 8.2

Defines the condition plugin annotation object.

Plugin namespace: Plugin\Commerce\Condition.

Hierarchy

Expanded class hierarchy of CommerceCondition

20 classes are annotated with CommerceCondition
OrderBillingAddress in modules/order/src/Plugin/Commerce/Condition/OrderBillingAddress.php
Provides the billing address condition for orders.
OrderCurrency in modules/order/src/Plugin/Commerce/Condition/OrderCurrency.php
Provides the currency condition for orders.
OrderCustomer in modules/order/src/Plugin/Commerce/Condition/OrderCustomer.php
Provides the customer condition for orders.
OrderCustomerRole in modules/order/src/Plugin/Commerce/Condition/OrderCustomerRole.php
Provides the customer role condition for orders.
OrderEmail in modules/order/src/Plugin/Commerce/Condition/OrderEmail.php
Provides the Email address condition for orders.

... See full list

File

src/Annotation/CommerceCondition.php, line 15

Namespace

Drupal\commerce\Annotation
View source
class CommerceCondition extends Plugin {
  use StringTranslationTrait;

  /**
   * The plugin ID.
   *
   * @var string
   */
  public $id;

  /**
   * The condition label.
   *
   * @var \Drupal\Core\Annotation\Translation
   *
   * @ingroup plugin_translatable
   */
  public $label;

  /**
   * The condition display label.
   *
   * Shown in the condition UI when enabling/disabling a condition.
   * Defaults to the main label.
   *
   * @var \Drupal\Core\Annotation\Translation
   *
   * @ingroup plugin_translatable
   */
  public $display_label;

  /**
   * The condition category.
   *
   * @var \Drupal\Core\Annotation\Translation
   *
   * @ingroup plugin_translatable
   */
  public $category;

  /**
   * The condition entity type ID.
   *
   * This is the entity type ID of the entity passed to the plugin during
   * evaluation. For example: 'commerce_order'.
   *
   * @var string
   */
  public $entity_type;

  /**
   * The parent entity type ID.
   *
   * This is the entity type ID of the entity that embeds the conditions.
   * For example: 'commerce_promotion'.
   *
   * When specified, a condition will only be available on that entity type.
   *
   * @var string
   */
  public $parent_entity_type;

  /**
   * The condition weight.
   *
   * Used when sorting the condition list in the UI.
   *
   * @var int
   */
  public $weight = 0;

  /**
   * Constructs a new CommerceCondition object.
   *
   * @param array $values
   *   The annotation values.
   */
  public function __construct(array $values) {
    if (empty($values['display_label'])) {
      $values['display_label'] = $values['label'];
    }
    if (empty($values['category'])) {
      $values['category'] = $this
        ->t('Other');
    }
    parent::__construct($values);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CommerceCondition::$category public property The condition category.
CommerceCondition::$display_label public property The condition display label.
CommerceCondition::$entity_type public property The condition entity type ID.
CommerceCondition::$id public property The plugin ID.
CommerceCondition::$label public property The condition label.
CommerceCondition::$parent_entity_type public property The parent entity type ID.
CommerceCondition::$weight public property The condition weight.
CommerceCondition::__construct public function Constructs a new CommerceCondition object. Overrides Plugin::__construct
Plugin::$definition protected property The plugin definition read from the class annotation. 1
Plugin::get public function Gets the value of an annotation. Overrides AnnotationInterface::get 5
Plugin::getClass public function Gets the class of the annotated class. Overrides AnnotationInterface::getClass
Plugin::getId public function Gets the unique ID for this annotated class. Overrides AnnotationInterface::getId
Plugin::getProvider public function Gets the name of the provider of the annotated class. Overrides AnnotationInterface::getProvider
Plugin::parse protected function Parses an annotation into its definition.
Plugin::setClass public function Sets the class of the annotated class. Overrides AnnotationInterface::setClass
Plugin::setProvider public function Sets the name of the provider of the annotated class. Overrides AnnotationInterface::setProvider
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.