You are here

interface EntityTraitInterface in Commerce Core 8.2

Defines the interface for entity traits.

An entity trait represents a behavior that can be attached to a specific entity bundle, by acting as a marker ("product is shippable") and/or providing a set of fields.

Hierarchy

Expanded class hierarchy of EntityTraitInterface

All classes that implement EntityTraitInterface

2 files declare their use of EntityTraitInterface
EntityTraitManager.php in src/EntityTraitManager.php
EntityTraitManagerInterface.php in src/EntityTraitManagerInterface.php

File

src/Plugin/Commerce/EntityTrait/EntityTraitInterface.php, line 14

Namespace

Drupal\commerce\Plugin\Commerce\EntityTrait
View source
interface EntityTraitInterface extends PluginInspectionInterface {

  /**
   * Gets the entity trait label.
   *
   * @return string
   *   The entity trait label.
   */
  public function getLabel();

  /**
   * Gets the entity type IDs.
   *
   * These are the entity types that can have this trait.
   * If empty, defaults to all entity types.
   *
   * @return string[]
   *   The entity type IDs.
   */
  public function getEntityTypeIds();

  /**
   * Builds the field definitions.
   *
   * THe provided field definitions will be created as configurable
   * fields when the entity trait is installed for an entity type/bundle.
   *
   * @return \Drupal\entity\BundleFieldDefinition[]
   *   An array of field definitions, keyed by field name.
   */
  public function buildFieldDefinitions();

}

Members

Namesort descending Modifiers Type Description Overrides
EntityTraitInterface::buildFieldDefinitions public function Builds the field definitions. 1
EntityTraitInterface::getEntityTypeIds public function Gets the entity type IDs. 1
EntityTraitInterface::getLabel public function Gets the entity trait label. 1
PluginInspectionInterface::getPluginDefinition public function Gets the definition of the plugin implementation. 4
PluginInspectionInterface::getPluginId public function Gets the plugin_id of the plugin instance. 2