You are here

abstract class EntityDisplayBase in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Entity/EntityDisplayBase.php \Drupal\Core\Entity\EntityDisplayBase

Provides a common base class for entity view and form displays.

Hierarchy

Expanded class hierarchy of EntityDisplayBase

2 files declare their use of EntityDisplayBase
EntityFormDisplay.php in core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php
Contains \Drupal\Core\Entity\Entity\EntityFormDisplay.
EntityViewDisplay.php in core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php
Contains \Drupal\Core\Entity\Entity\EntityViewDisplay.

File

core/lib/Drupal/Core/Entity/EntityDisplayBase.php, line 18
Contains \Drupal\Core\Entity\EntityDisplayBase.

Namespace

Drupal\Core\Entity
View source
abstract class EntityDisplayBase extends ConfigEntityBase implements EntityDisplayInterface {

  /**
   * The 'mode' for runtime EntityDisplay objects used to render entities with
   * arbitrary display options rather than a configured view mode or form mode.
   *
   * @todo Prevent creation of a mode with this ID
   *   https://www.drupal.org/node/2410727
   */
  const CUSTOM_MODE = '_custom';

  /**
   * Unique ID for the config entity.
   *
   * @var string
   */
  protected $id;

  /**
   * Entity type to be displayed.
   *
   * @var string
   */
  protected $targetEntityType;

  /**
   * Bundle to be displayed.
   *
   * @var string
   */
  protected $bundle;

  /**
   * A list of field definitions eligible for configuration in this display.
   *
   * @var \Drupal\Core\Field\FieldDefinitionInterface[]
   */
  protected $fieldDefinitions;

  /**
   * View or form mode to be displayed.
   *
   * @var string
   */
  protected $mode = self::CUSTOM_MODE;

  /**
   * Whether this display is enabled or not. If the entity (form) display
   * is disabled, we'll fall back to the 'default' display.
   *
   * @var bool
   */
  protected $status;

  /**
   * List of component display options, keyed by component name.
   *
   * @var array
   */
  protected $content = array();

  /**
   * List of components that are set to be hidden.
   *
   * @var array
   */
  protected $hidden = array();

  /**
   * The original view or form mode that was requested (case of view/form modes
   * being configured to fall back to the 'default' display).
   *
   * @var string
   */
  protected $originalMode;

  /**
   * The plugin objects used for this display, keyed by field name.
   *
   * @var array
   */
  protected $plugins = array();

  /**
   * Context in which this entity will be used (e.g. 'display', 'form').
   *
   * @var string
   */
  protected $displayContext;

  /**
   * The plugin manager used by this entity type.
   *
   * @var \Drupal\Component\Plugin\PluginManagerBase
   */
  protected $pluginManager;

  /**
   * The renderer.
   *
   * @var \Drupal\Core\Render\RendererInterface
   */
  protected $renderer;

  /**
   * {@inheritdoc}
   */
  public function __construct(array $values, $entity_type) {
    if (!isset($values['targetEntityType']) || !isset($values['bundle'])) {
      throw new \InvalidArgumentException('Missing required properties for an EntityDisplay entity.');
    }
    if (!$this
      ->entityManager()
      ->getDefinition($values['targetEntityType'])
      ->isSubclassOf('\\Drupal\\Core\\Entity\\FieldableEntityInterface')) {
      throw new \InvalidArgumentException('EntityDisplay entities can only handle fieldable entity types.');
    }
    $this->renderer = \Drupal::service('renderer');

    // A plugin manager and a context type needs to be set by extending classes.
    if (!isset($this->pluginManager)) {
      throw new \RuntimeException('Missing plugin manager.');
    }
    if (!isset($this->displayContext)) {
      throw new \RuntimeException('Missing display context type.');
    }
    parent::__construct($values, $entity_type);
    $this->originalMode = $this->mode;
    $this
      ->init();
  }

  /**
   * Initializes the display.
   *
   * This fills in default options for components:
   * - that are not explicitly known as either "visible" or "hidden" in the
   *   display,
   * - or that are not supposed to be configurable.
   */
  protected function init() {

    // Only populate defaults for "official" view modes and form modes.
    if ($this->mode !== static::CUSTOM_MODE) {

      // Fill in defaults for extra fields.
      $context = $this->displayContext == 'view' ? 'display' : $this->displayContext;
      $extra_fields = \Drupal::entityManager()
        ->getExtraFields($this->targetEntityType, $this->bundle);
      $extra_fields = isset($extra_fields[$context]) ? $extra_fields[$context] : array();
      foreach ($extra_fields as $name => $definition) {
        if (!isset($this->content[$name]) && !isset($this->hidden[$name])) {

          // Extra fields are visible by default unless they explicitly say so.
          if (!isset($definition['visible']) || $definition['visible'] == TRUE) {
            $this->content[$name] = array(
              'weight' => $definition['weight'],
            );
          }
          else {
            $this->hidden[$name] = TRUE;
          }
        }
      }

      // Fill in defaults for fields.
      $fields = $this
        ->getFieldDefinitions();
      foreach ($fields as $name => $definition) {
        if (!$definition
          ->isDisplayConfigurable($this->displayContext) || !isset($this->content[$name]) && !isset($this->hidden[$name])) {
          $options = $definition
            ->getDisplayOptions($this->displayContext);
          if (!empty($options['type']) && $options['type'] == 'hidden') {
            $this->hidden[$name] = TRUE;
          }
          elseif ($options) {
            $this->content[$name] = $this->pluginManager
              ->prepareConfiguration($definition
              ->getType(), $options);
          }

          // Note: (base) fields that do not specify display options are not
          // tracked in the display at all, in order to avoid cluttering the
          // configuration that gets saved back.
        }
      }
    }
  }

  /**
   * {@inheritdoc}
   */
  public function getTargetEntityTypeId() {
    return $this->targetEntityType;
  }

  /**
   * {@inheritdoc}
   */
  public function getMode() {
    return $this
      ->get('mode');
  }

  /**
   * {@inheritdoc}
   */
  public function getOriginalMode() {
    return $this
      ->get('originalMode');
  }

  /**
   * {@inheritdoc}
   */
  public function getTargetBundle() {
    return $this->bundle;
  }

  /**
   * {@inheritdoc}
   */
  public function setTargetBundle($bundle) {
    $this
      ->set('bundle', $bundle);
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function id() {
    return $this->targetEntityType . '.' . $this->bundle . '.' . $this->mode;
  }

  /**
   * {@inheritdoc}
   */
  public function preSave(EntityStorageInterface $storage, $update = TRUE) {
    ksort($this->content);
    ksort($this->hidden);
    parent::preSave($storage, $update);
  }

  /**
   * {@inheritdoc}
   */
  public function calculateDependencies() {
    parent::calculateDependencies();
    $target_entity_type = $this
      ->entityManager()
      ->getDefinition($this->targetEntityType);

    // Create dependency on the bundle.
    $bundle_config_dependency = $target_entity_type
      ->getBundleConfigDependency($this->bundle);
    $this
      ->addDependency($bundle_config_dependency['type'], $bundle_config_dependency['name']);

    // If field.module is enabled, add dependencies on 'field_config' entities
    // for both displayed and hidden fields. We intentionally leave out base
    // field overrides, since the field still exists without them.
    if (\Drupal::moduleHandler()
      ->moduleExists('field')) {
      $components = $this->content + $this->hidden;
      $field_definitions = $this
        ->entityManager()
        ->getFieldDefinitions($this->targetEntityType, $this->bundle);
      foreach (array_intersect_key($field_definitions, $components) as $field_name => $field_definition) {
        if ($field_definition instanceof ConfigEntityInterface && $field_definition
          ->getEntityTypeId() == 'field_config') {
          $this
            ->addDependency('config', $field_definition
            ->getConfigDependencyName());
        }
      }
    }

    // Depend on configured modes.
    if ($this->mode != 'default') {
      $mode_entity = $this
        ->entityManager()
        ->getStorage('entity_' . $this->displayContext . '_mode')
        ->load($target_entity_type
        ->id() . '.' . $this->mode);
      $this
        ->addDependency('config', $mode_entity
        ->getConfigDependencyName());
    }
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function toArray() {
    $properties = parent::toArray();

    // Do not store options for fields whose display is not set to be
    // configurable.
    foreach ($this
      ->getFieldDefinitions() as $field_name => $definition) {
      if (!$definition
        ->isDisplayConfigurable($this->displayContext)) {
        unset($properties['content'][$field_name]);
        unset($properties['hidden'][$field_name]);
      }
    }
    return $properties;
  }

  /**
   * {@inheritdoc}
   */
  public function createCopy($mode) {
    $display = $this
      ->createDuplicate();
    $display->mode = $display->originalMode = $mode;
    return $display;
  }

  /**
   * {@inheritdoc}
   */
  public function getComponents() {
    return $this->content;
  }

  /**
   * {@inheritdoc}
   */
  public function getComponent($name) {
    return isset($this->content[$name]) ? $this->content[$name] : NULL;
  }

  /**
   * {@inheritdoc}
   */
  public function setComponent($name, array $options = array()) {

    // If no weight specified, make sure the field sinks at the bottom.
    if (!isset($options['weight'])) {
      $max = $this
        ->getHighestWeight();
      $options['weight'] = isset($max) ? $max + 1 : 0;
    }

    // For a field, fill in default options.
    if ($field_definition = $this
      ->getFieldDefinition($name)) {
      $options = $this->pluginManager
        ->prepareConfiguration($field_definition
        ->getType(), $options);
    }

    // Ensure we always have an empty settings and array.
    $options += [
      'settings' => [],
      'third_party_settings' => [],
    ];
    $this->content[$name] = $options;
    unset($this->hidden[$name]);
    unset($this->plugins[$name]);
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function removeComponent($name) {
    $this->hidden[$name] = TRUE;
    unset($this->content[$name]);
    unset($this->plugins[$name]);
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function getHighestWeight() {
    $weights = array();

    // Collect weights for the components in the display.
    foreach ($this->content as $options) {
      if (isset($options['weight'])) {
        $weights[] = $options['weight'];
      }
    }

    // Let other modules feedback about their own additions.
    $weights = array_merge($weights, \Drupal::moduleHandler()
      ->invokeAll('field_info_max_weight', array(
      $this->targetEntityType,
      $this->bundle,
      $this->displayContext,
      $this->mode,
    )));
    return $weights ? max($weights) : NULL;
  }

  /**
   * Gets the field definition of a field.
   */
  protected function getFieldDefinition($field_name) {
    $definitions = $this
      ->getFieldDefinitions();
    return isset($definitions[$field_name]) ? $definitions[$field_name] : NULL;
  }

  /**
   * Gets the definitions of the fields that are candidate for display.
   */
  protected function getFieldDefinitions() {
    if (!isset($this->fieldDefinitions)) {
      $definitions = \Drupal::entityManager()
        ->getFieldDefinitions($this->targetEntityType, $this->bundle);

      // For "official" view modes and form modes, ignore fields whose
      // definition states they should not be displayed.
      if ($this->mode !== static::CUSTOM_MODE) {
        $definitions = array_filter($definitions, array(
          $this,
          'fieldHasDisplayOptions',
        ));
      }
      $this->fieldDefinitions = $definitions;
    }
    return $this->fieldDefinitions;
  }

  /**
   * Determines if a field has options for a given display.
   *
   * @param FieldDefinitionInterface $definition
   *   A field definition.
   * @return array|null
   */
  private function fieldHasDisplayOptions(FieldDefinitionInterface $definition) {

    // The display only cares about fields that specify display options.
    // Discard base fields that are not rendered through formatters / widgets.
    return $definition
      ->getDisplayOptions($this->displayContext);
  }

  /**
   * {@inheritdoc}
   */
  public function onDependencyRemoval(array $dependencies) {
    $changed = parent::onDependencyRemoval($dependencies);
    foreach ($dependencies['config'] as $entity) {
      if ($entity
        ->getEntityTypeId() == 'field_config') {

        // Remove components for fields that are being deleted.
        $this
          ->removeComponent($entity
          ->getName());
        unset($this->hidden[$entity
          ->getName()]);
        $changed = TRUE;
      }
    }
    foreach ($this
      ->getComponents() as $name => $component) {
      if ($renderer = $this
        ->getRenderer($name)) {
        if (in_array($renderer
          ->getPluginDefinition()['provider'], $dependencies['module'])) {

          // Revert to the defaults if the plugin that supplies the widget or
          // formatter depends on a module that is being uninstalled.
          $this
            ->setComponent($name);
          $changed = TRUE;
        }

        // Give this component the opportunity to react on dependency removal.
        $component_removed_dependencies = $this
          ->getPluginRemovedDependencies($renderer
          ->calculateDependencies(), $dependencies);
        if ($component_removed_dependencies) {
          if ($renderer
            ->onDependencyRemoval($component_removed_dependencies)) {

            // Update component settings to reflect changes.
            $component['settings'] = $renderer
              ->getSettings();
            $component['third_party_settings'] = [];
            foreach ($renderer
              ->getThirdPartyProviders() as $module) {
              $component['third_party_settings'][$module] = $renderer
                ->getThirdPartySettings($module);
            }
            $this
              ->setComponent($name, $component);
            $changed = TRUE;
          }

          // If there are unresolved deleted dependencies left, disable this
          // component to avoid the removal of the entire display entity.
          if ($this
            ->getPluginRemovedDependencies($renderer
            ->calculateDependencies(), $dependencies)) {
            $this
              ->removeComponent($name);
            $arguments = [
              '@display' => (string) $this
                ->getEntityType()
                ->getLabel(),
              '@id' => $this
                ->id(),
              '@name' => $name,
            ];
            $this
              ->getLogger()
              ->warning("@display '@id': Component '@name' was disabled because its settings depend on removed dependencies.", $arguments);
            $changed = TRUE;
          }
        }
      }
    }
    return $changed;
  }

  /**
   * Returns the plugin dependencies being removed.
   *
   * The function recursively computes the intersection between all plugin
   * dependencies and all removed dependencies.
   *
   * Note: The two arguments do not have the same structure.
   *
   * @param array[] $plugin_dependencies
   *   A list of dependencies having the same structure as the return value of
   *   ConfigEntityInterface::calculateDependencies().
   * @param array[] $removed_dependencies
   *   A list of dependencies having the same structure as the input argument of
   *   ConfigEntityInterface::onDependencyRemoval().
   *
   * @return array
   *   A recursively computed intersection.
   *
   * @see \Drupal\Core\Config\Entity\ConfigEntityInterface::calculateDependencies()
   * @see \Drupal\Core\Config\Entity\ConfigEntityInterface::onDependencyRemoval()
   */
  protected function getPluginRemovedDependencies(array $plugin_dependencies, array $removed_dependencies) {
    $intersect = [];
    foreach ($plugin_dependencies as $type => $dependencies) {
      if ($removed_dependencies[$type]) {

        // Config and content entities have the dependency names as keys while
        // module and theme dependencies are indexed arrays of dependency names.
        // @see \Drupal\Core\Config\ConfigManager::callOnDependencyRemoval()
        if (in_array($type, [
          'config',
          'content',
        ])) {
          $removed = array_intersect_key($removed_dependencies[$type], array_flip($dependencies));
        }
        else {
          $removed = array_values(array_intersect($removed_dependencies[$type], $dependencies));
        }
        if ($removed) {
          $intersect[$type] = $removed;
        }
      }
    }
    return $intersect;
  }

  /**
   * {@inheritdoc}
   */
  public function __sleep() {

    // Only store the definition, not external objects or derived data.
    $keys = array_keys($this
      ->toArray());

    // In addition, we need to keep the entity type and the "is new" status.
    $keys[] = 'entityTypeId';
    $keys[] = 'enforceIsNew';

    // Keep track of the serialized keys, to avoid calling toArray() again in
    // __wakeup(). Because of the way __sleep() works, the data has to be
    // present in the object to be included in the serialized values.
    $keys[] = '_serializedKeys';
    $this->_serializedKeys = $keys;
    return $keys;
  }

  /**
   * {@inheritdoc}
   */
  public function __wakeup() {

    // Determine what were the properties from toArray() that were saved in
    // __sleep().
    $keys = $this->_serializedKeys;
    unset($this->_serializedKeys);
    $values = array_intersect_key(get_object_vars($this), array_flip($keys));

    // Run those values through the __construct(), as if they came from a
    // regular entity load.
    $this
      ->__construct($values, $this->entityTypeId);
  }

  /**
   * Provides the 'system' channel logger service.
   *
   * @return \Psr\Log\LoggerInterface
   *   The 'system' channel logger.
   */
  protected function getLogger() {
    return \Drupal::logger('system');
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ConfigEntityBase::$isSyncing private property Whether the config is being created, updated or deleted through the import process.
ConfigEntityBase::$isUninstalling private property Whether the config is being deleted by the uninstall process.
ConfigEntityBase::$langcode protected property The language code of the entity's default language.
ConfigEntityBase::$originalId protected property The original ID of the configuration entity.
ConfigEntityBase::$pluginConfigKey protected property The name of the property that is used to store plugin configuration.
ConfigEntityBase::$third_party_settings protected property Third party entity settings.
ConfigEntityBase::$trustedData protected property Trust supplied data and not use configuration schema on save.
ConfigEntityBase::$uuid protected property The UUID for this entity.
ConfigEntityBase::addDependency protected function Overrides \Drupal\Core\Entity\DependencyTrait:addDependency().
ConfigEntityBase::createDuplicate public function Creates a duplicate of the entity. Overrides Entity::createDuplicate 1
ConfigEntityBase::disable public function Disables the configuration entity. Overrides ConfigEntityInterface::disable 1
ConfigEntityBase::enable public function Enables the configuration entity. Overrides ConfigEntityInterface::enable
ConfigEntityBase::get public function Returns the value of a property. Overrides ConfigEntityInterface::get
ConfigEntityBase::getCacheTagsToInvalidate public function Returns the cache tags that should be used to invalidate caches. Overrides Entity::getCacheTagsToInvalidate 1
ConfigEntityBase::getConfigDependencyName public function Gets the configuration dependency name. Overrides Entity::getConfigDependencyName
ConfigEntityBase::getConfigManager protected static function Gets the configuration manager.
ConfigEntityBase::getConfigTarget public function Gets the configuration target identifier for the entity. Overrides Entity::getConfigTarget
ConfigEntityBase::getDependencies public function Gets the configuration dependencies. Overrides ConfigEntityInterface::getDependencies
ConfigEntityBase::getOriginalId public function Gets the original ID. Overrides Entity::getOriginalId
ConfigEntityBase::getThirdPartyProviders public function Gets the list of third parties that store information. Overrides ThirdPartySettingsInterface::getThirdPartyProviders
ConfigEntityBase::getThirdPartySetting public function Gets the value of a third-party setting. Overrides ThirdPartySettingsInterface::getThirdPartySetting
ConfigEntityBase::getThirdPartySettings public function Gets all third-party settings of a given module. Overrides ThirdPartySettingsInterface::getThirdPartySettings
ConfigEntityBase::getTypedConfig protected function Gets the typed config manager.
ConfigEntityBase::hasTrustedData public function Gets whether on not the data is trusted. Overrides ConfigEntityInterface::hasTrustedData
ConfigEntityBase::invalidateTagsOnDelete protected static function Override to never invalidate the individual entities' cache tags; the config system already invalidates them. Overrides Entity::invalidateTagsOnDelete
ConfigEntityBase::invalidateTagsOnSave protected function Override to never invalidate the entity's cache tag; the config system already invalidates it. Overrides Entity::invalidateTagsOnSave
ConfigEntityBase::isInstallable public function Checks whether this entity is installable. Overrides ConfigEntityInterface::isInstallable 2
ConfigEntityBase::isNew public function Overrides Entity::isNew(). Overrides Entity::isNew
ConfigEntityBase::isSyncing public function Returns whether this entity is being changed as part of an import process. Overrides ConfigEntityInterface::isSyncing
ConfigEntityBase::isUninstalling public function Returns whether this entity is being changed during the uninstall process. Overrides ConfigEntityInterface::isUninstalling
ConfigEntityBase::link public function Deprecated way of generating a link to the entity. See toLink(). Overrides Entity::link
ConfigEntityBase::preDelete public static function Acts on entities before they are deleted and before hooks are invoked. Overrides Entity::preDelete 7
ConfigEntityBase::save public function Saves an entity permanently. Overrides Entity::save 1
ConfigEntityBase::set public function Sets the value of a property. Overrides ConfigEntityInterface::set 1
ConfigEntityBase::setOriginalId public function Sets the original ID. Overrides Entity::setOriginalId
ConfigEntityBase::setStatus public function Sets the status of the configuration entity. Overrides ConfigEntityInterface::setStatus 1
ConfigEntityBase::setSyncing public function Sets the status of the isSyncing flag. Overrides ConfigEntityInterface::setSyncing
ConfigEntityBase::setThirdPartySetting public function Sets the value of a third-party setting. Overrides ThirdPartySettingsInterface::setThirdPartySetting
ConfigEntityBase::setUninstalling public function
ConfigEntityBase::sort public static function Helper callback for uasort() to sort configuration entities by weight and label. 6
ConfigEntityBase::status public function Returns whether the configuration entity is enabled. Overrides ConfigEntityInterface::status 2
ConfigEntityBase::toUrl public function Gets the URL object for the entity. Overrides Entity::toUrl
ConfigEntityBase::trustData public function Sets that the data should be trusted. Overrides ConfigEntityInterface::trustData 1
ConfigEntityBase::unsetThirdPartySetting public function Unsets a third-party setting. Overrides ThirdPartySettingsInterface::unsetThirdPartySetting
ConfigEntityBase::url public function Gets the public URL for this entity. Overrides Entity::url
ConfigEntityBase::urlInfo public function Gets the URL object for the entity. Overrides Entity::urlInfo
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function Aliased as: traitSleep 1
DependencyTrait::$dependencies protected property The object's dependencies. 1
DependencyTrait::addDependencies protected function Adds multiple dependencies.
DependencyTrait::addDependency protected function Adds a dependency. Aliased as: addDependencyTrait
Entity::$enforceIsNew protected property Boolean indicating whether the entity should be forced to be new.
Entity::$entityTypeId protected property The entity type.
Entity::$typedData protected property A typed data object wrapping this entity.
Entity::access public function Checks data value access. Overrides AccessibleInterface::access 1
Entity::bundle public function Gets the bundle of the entity. Overrides EntityInterface::bundle 1
Entity::create public static function Overrides EntityInterface::create
Entity::delete public function Deletes an entity permanently. Overrides EntityInterface::delete 2
Entity::enforceIsNew public function Enforces an entity to be new. Overrides EntityInterface::enforceIsNew
Entity::entityManager Deprecated protected function Gets the entity manager.
Entity::entityTypeManager protected function Gets the entity type manager.
Entity::getCacheContexts public function The cache contexts associated with this object. Overrides RefinableCacheableDependencyTrait::getCacheContexts
Entity::getCacheMaxAge public function The maximum age for which this object may be cached. Overrides RefinableCacheableDependencyTrait::getCacheMaxAge
Entity::getCacheTags public function The cache tags associated with this object. Overrides RefinableCacheableDependencyTrait::getCacheTags
Entity::getConfigDependencyKey public function Gets the key that is used to store configuration dependencies. Overrides EntityInterface::getConfigDependencyKey
Entity::getEntityType public function Gets the entity type definition. Overrides EntityInterface::getEntityType
Entity::getEntityTypeId public function Gets the ID of the type of the entity. Overrides EntityInterface::getEntityTypeId
Entity::getTypedData public function Gets a typed data object for this entity object. Overrides EntityInterface::getTypedData
Entity::hasLinkTemplate public function Indicates if a link template exists for a given key. Overrides EntityInterface::hasLinkTemplate
Entity::label public function Gets the label of the entity. Overrides EntityInterface::label 5
Entity::language public function Gets the language of the entity. Overrides EntityInterface::language 1
Entity::languageManager protected function Gets the language manager.
Entity::linkTemplates protected function Gets an array link templates. 1
Entity::load public static function Overrides EntityInterface::load
Entity::loadMultiple public static function Overrides EntityInterface::loadMultiple
Entity::postCreate public function Acts on an entity after it is created but before hooks are invoked. Overrides EntityInterface::postCreate 4
Entity::postDelete public static function Acts on deleted entities before the delete hook is invoked. Overrides EntityInterface::postDelete 14
Entity::postLoad public static function Acts on loaded entities. Overrides EntityInterface::postLoad 2
Entity::postSave public function Acts on a saved entity before the insert or update hook is invoked. Overrides EntityInterface::postSave 20
Entity::preCreate public static function Changes the values of an entity before it is created. Overrides EntityInterface::preCreate 6
Entity::referencedEntities public function Gets a list of entities referenced by this entity. Overrides EntityInterface::referencedEntities 1
Entity::toLink public function Generates the HTML for a link to this entity. Overrides EntityInterface::toLink
Entity::uriRelationships public function Returns a list of URI relationships supported by this entity. Overrides EntityInterface::uriRelationships
Entity::urlRouteParameters protected function Gets an array of placeholders for this entity. 1
Entity::uuid public function Gets the entity UUID (Universally Unique Identifier). Overrides EntityInterface::uuid 1
Entity::uuidGenerator protected function Gets the UUID generator.
EntityDisplayBase::$bundle protected property Bundle to be displayed.
EntityDisplayBase::$content protected property List of component display options, keyed by component name.
EntityDisplayBase::$displayContext protected property Context in which this entity will be used (e.g. 'display', 'form'). 2
EntityDisplayBase::$fieldDefinitions protected property A list of field definitions eligible for configuration in this display.
EntityDisplayBase::$hidden protected property List of components that are set to be hidden.
EntityDisplayBase::$id protected property Unique ID for the config entity.
EntityDisplayBase::$mode protected property View or form mode to be displayed.
EntityDisplayBase::$originalMode protected property The original view or form mode that was requested (case of view/form modes being configured to fall back to the 'default' display).
EntityDisplayBase::$pluginManager protected property The plugin manager used by this entity type.
EntityDisplayBase::$plugins protected property The plugin objects used for this display, keyed by field name.
EntityDisplayBase::$renderer protected property The renderer.
EntityDisplayBase::$status protected property Whether this display is enabled or not. If the entity (form) display is disabled, we'll fall back to the 'default' display. Overrides ConfigEntityBase::$status
EntityDisplayBase::$targetEntityType protected property Entity type to be displayed.
EntityDisplayBase::calculateDependencies public function Calculates dependencies and stores them in the dependency property. Overrides ConfigEntityBase::calculateDependencies
EntityDisplayBase::createCopy public function Creates a duplicate of the entity display object on a different view mode. Overrides EntityDisplayInterface::createCopy
EntityDisplayBase::CUSTOM_MODE constant The 'mode' for runtime EntityDisplay objects used to render entities with arbitrary display options rather than a configured view mode or form mode.
EntityDisplayBase::fieldHasDisplayOptions private function Determines if a field has options for a given display.
EntityDisplayBase::getComponent public function Gets the display options set for a component. Overrides EntityDisplayInterface::getComponent
EntityDisplayBase::getComponents public function Gets the display options for all components. Overrides EntityDisplayInterface::getComponents
EntityDisplayBase::getFieldDefinition protected function Gets the field definition of a field.
EntityDisplayBase::getFieldDefinitions protected function Gets the definitions of the fields that are candidate for display.
EntityDisplayBase::getHighestWeight public function Gets the highest weight of the components in the display. Overrides EntityDisplayInterface::getHighestWeight
EntityDisplayBase::getLogger protected function Provides the 'system' channel logger service.
EntityDisplayBase::getMode public function Gets the view or form mode to be displayed. Overrides EntityDisplayInterface::getMode
EntityDisplayBase::getOriginalMode public function Gets the original view or form mode that was requested. Overrides EntityDisplayInterface::getOriginalMode
EntityDisplayBase::getPluginRemovedDependencies protected function Returns the plugin dependencies being removed.
EntityDisplayBase::getTargetBundle public function Gets the bundle to be displayed. Overrides EntityDisplayInterface::getTargetBundle
EntityDisplayBase::getTargetEntityTypeId public function Gets the entity type for which this display is used. Overrides EntityDisplayInterface::getTargetEntityTypeId
EntityDisplayBase::id public function Gets the identifier. Overrides Entity::id
EntityDisplayBase::init protected function Initializes the display.
EntityDisplayBase::onDependencyRemoval public function Informs the entity that entities it depends on will be deleted. Overrides ConfigEntityBase::onDependencyRemoval
EntityDisplayBase::preSave public function Acts on an entity before the presave hook is invoked. Overrides ConfigEntityBase::preSave
EntityDisplayBase::removeComponent public function Sets a component to be hidden. Overrides EntityDisplayInterface::removeComponent
EntityDisplayBase::setComponent public function Sets the display options for a component. Overrides EntityDisplayInterface::setComponent
EntityDisplayBase::setTargetBundle public function Sets the bundle to be displayed. Overrides EntityDisplayInterface::setTargetBundle
EntityDisplayBase::toArray public function Gets an array of all property values. Overrides ConfigEntityBase::toArray
EntityDisplayBase::__construct public function Constructs an Entity object. Overrides ConfigEntityBase::__construct 2
EntityDisplayBase::__sleep public function Overrides Entity::__sleep
EntityDisplayBase::__wakeup public function Overrides DependencySerializationTrait::__wakeup
EntityDisplayInterface::getRenderer public function Gets the renderer plugin for a field (e.g. widget, formatter). 2
EntityWithPluginCollectionInterface::getPluginCollections public function Gets the plugin collections used by this entity. 7
PluginDependencyTrait::calculatePluginDependencies protected function Calculates and adds dependencies of a specific plugin instance. 1
RefinableCacheableDependencyTrait::$cacheContexts protected property Cache contexts.
RefinableCacheableDependencyTrait::$cacheMaxAge protected property Cache max-age.
RefinableCacheableDependencyTrait::$cacheTags protected property Cache tags.
RefinableCacheableDependencyTrait::addCacheableDependency public function 1
RefinableCacheableDependencyTrait::addCacheContexts public function
RefinableCacheableDependencyTrait::addCacheTags public function
RefinableCacheableDependencyTrait::mergeCacheMaxAge public function