You are here

class FlexiformEntityFormDisplay in Flexiform 8

Defines a class to extend EntityFormDisplays.

To work with multiple entity forms.

Hierarchy

Expanded class hierarchy of FlexiformEntityFormDisplay

9 files declare their use of FlexiformEntityFormDisplay
ContainerFactoryFormComponentInterface.php in src/FormComponent/ContainerFactoryFormComponentInterface.php
CustomTextComponent.php in src/Plugin/FormComponentType/CustomTextComponent.php
EntityFormBlockDeriver.php in src/Plugin/Deriver/EntityFormBlockDeriver.php
FieldWidgetComponent.php in src/Plugin/FormComponentType/FieldWidgetComponent.php
flexiform.module in ./flexiform.module
Allow multiple entities to be used in an entity form display.

... See full list

File

src/FlexiformEntityFormDisplay.php, line 21

Namespace

Drupal\flexiform
View source
class FlexiformEntityFormDisplay extends EntityFormDisplay implements FlexiformEntityFormDisplayInterface {

  /**
   * The base entity namespace.
   *
   * @var string
   */
  protected $baseEntityNamespace = '';

  /**
   * The form entity configuration.
   *
   * @var array
   */
  protected $formEntities = [];

  /**
   * The form enhancers.
   *
   * @var array
   */
  protected $formEnhancers = [];

  /**
   * The flexiform form Entity Manager.
   *
   * @var \Drupal\flexiform\FormEntity\FlexiformFormEntityManager
   */
  protected $formEntityManager;

  /**
   * What entities the form entity manager has been provided with.
   *
   * If more entities are supplied build a new entity manager.
   *
   * @var string[]
   */
  protected $formEntityManagerSuppliedNamespaces;

  /**
   * Component types.
   *
   * @var \Drupal\flexiform\FormComponent\FormComponentTypeInterface[]
   */
  protected $componentTypePlugins = [];
  protected $providedEntities = [];

  /**
   * Collect the render display for a given entity_type_id and bundle.
   *
   * @param string $entity_type
   *   The entity type id.
   * @param $bundle
   * @param $form_mode
   *
   * @return \Drupal\Core\Entity\Display\EntityFormDisplayInterface
   */
  public static function collectRenderDisplayLight($entity_type, $bundle, $form_mode) {

    // Check the existence and status of:
    // - the display for the form mode,
    // - the 'default' display.
    if ($form_mode != 'default') {
      $candidate_ids[] = $entity_type . '.' . $bundle . '.' . $form_mode;
    }
    $candidate_ids[] = $entity_type . '.' . $bundle . '.default';
    $results = \Drupal::entityQuery('entity_form_display')
      ->condition('id', $candidate_ids)
      ->condition('status', TRUE)
      ->execute();

    // Load the first valid candidate display, if any.
    $storage = \Drupal::entityManager()
      ->getStorage('entity_form_display');
    foreach ($candidate_ids as $candidate_id) {
      if (isset($results[$candidate_id])) {
        $display = $storage
          ->load($candidate_id);
        break;
      }
    }

    // Else create a fresh runtime object.
    if (empty($display)) {
      $display = $storage
        ->create([
        'targetEntityType' => $entity_type,
        'bundle' => $bundle,
        'mode' => $form_mode,
        'status' => TRUE,
      ]);
    }

    // Let the display know which form mode was originally requested.
    $display->originalMode = $form_mode;

    // Let modules alter the display.
    $display_context = [
      'entity_type' => $entity_type,
      'bundle' => $bundle,
      'form_mode' => $form_mode,
    ];
    \Drupal::moduleHandler()
      ->alter('entity_form_display', $display, $display_context);
    return $display;
  }

  /**
   * Get the regions needed to create the overview form.
   *
   * I don't understand why in core these two methods are on the form_object
   * rather than the EntityFormDisplay object itself. I have put them here
   * so that it's easier to get access to the correct regions.
   *
   * @see \Drupal\field_ui\Form\EntityDisplayFormBase::getRegions()
   *
   * @return array
   *   Example usage:
   *
   * @code
   *     return array(
   *       'content' => array(
   *         // label for the region.
   *         'title' => $this->t('Content'),
   *         // Indicates if the region is visible in the UI.
   *         'invisible' => TRUE,
   *         // A message to indicate that there is nothing to be displayed in
   *         // the region.
   *         'message' => $this->t('No field is displayed.'),
   *       ),
   *     );
   * @endcode
   */
  public function getRegions() {
    return [
      'content' => [
        'title' => t('Content'),
        'invisible' => TRUE,
        'message' => t('No component is displayed.'),
      ],
      'hidden' => [
        'title' => t('Disabled', [], [
          'context' => 'Plural',
        ]),
        'message' => t('No component is hidden.'),
      ],
    ];
  }

  /**
   * Returns an associative array of all regions.
   *
   * @return array
   *   An array containing the region options.
   *
   * @see \Drupal\field_ui\Form\EntityDisplayFormBase::getRegionOptions()
   */
  public function getRegionOptions() {
    $options = [];
    foreach ($this
      ->getRegions() as $region => $data) {
      $options[$region] = $data['title'];
    }
    return $options;
  }

  /**
   * {@inheritdoc}
   */
  public function preSave(EntityStorageInterface $storage, $update = TRUE) {

    // Allow syncing to change the settings.
    $enhancer_settings = $this
      ->getThirdPartySetting('flexiform', 'enhancer', []);
    foreach ($this->formEnhancers as $enhancer_name => $enhancer) {
      if ($enhancer instanceof ConfigurableFormEnhancerInterface) {

        // If we're syncing, update the enhancer.
        if ($this
          ->isSyncing()) {
          if (isset($enhancer_settings[$enhancer_name])) {
            $enhancer
              ->setConfiguration($enhancer_settings[$enhancer_name]);
          }
        }
        else {
          $config = $enhancer
            ->getConfiguration();
          $config['id'] = $enhancer
            ->getPluginId();
          $enhancer_settings[$enhancer_name] = $config;
        }
      }
    }

    // If not syncing, write our changes.
    if (!$this
      ->isSyncing()) {
      $this
        ->setThirdPartySetting('flexiform', 'enhancer', $enhancer_settings);
    }
    parent::preSave($storage, $update);
  }

  /**
   * {@inheritdoc}
   */
  public static function postLoad(EntityStorageInterface $storage, array &$entities) {
    foreach ($entities as $entity) {
      $entity
        ->initFormEntityConfig();
    }
    parent::postLoad($storage, $entities);
  }

  /**
   * Get the component plugin.
   *
   * @return \Drupal\flexiform\FormComponent\FormComponentInterface
   */
  public function getComponentPlugin($name, $options, FlexiformFormEntityManager $form_entity_manager) {
    $plugin_id = !empty($options['component_type']) ? $options['component_type'] : (empty($options['type']) ? 'extra_field' : 'field_widget');
    return $this
      ->getComponentTypePlugin($plugin_id, $form_entity_manager)
      ->getComponent($name, $options)
      ->setFormEntityManager($form_entity_manager);
  }

  /**
   * Get a compoenet type plugin.
   */
  public function getComponentTypePlugin($plugin_id, FlexiformFormEntityManager $formEntityManager) {
    if (empty($this->componentTypePlugins[$plugin_id])) {
      $this->componentTypePlugins[$plugin_id] = \Drupal::service('plugin.manager.flexiform.form_component_type')
        ->createInstance($plugin_id)
        ->setFormDisplay($this);
      if ($formEntityManager) {
        $this->componentTypePlugins[$plugin_id]
          ->setFormEntityManager($formEntityManager);
      }
    }
    return $this->componentTypePlugins[$plugin_id];
  }

  /**
   * Get the array of provided entities.
   */
  protected function getProvidedEntities(FormStateInterface $form_state, FieldableEntityInterface $base_entity = NULL) {
    $provided = [];
    if ($base_entity) {
      $provided[$this->baseEntityNamespace] = $base_entity;
    }
    $provided += $form_state
      ->get('form_entity_provided') ?: [];
    return $provided;
  }

  /**
   * {@inheritdoc}
   */
  public function buildForm(FieldableEntityInterface $entity, array &$form, FormStateInterface $form_state) {
    $this
      ->buildAdvancedForm($this
      ->getProvidedEntities($form_state, $entity), $form, $form_state);
  }

  /**
   * Build standalone form.
   *
   * A standalone form does not have a single base.
   * This allows the passing of a single array of provided entities.
   *
   * @param \Drupal\Core\Entity\FieldableEntityInterface[] $provided
   *   An array of provided entities keyed by namespace.
   * @param array $form
   *   The form array.
   * @param \Drupal\Core\Form\FormStateInterface $form_state
   *   The form state.
   */
  public function buildAdvancedForm(array $provided, array &$form, FormStateInterface $form_state) {

    // Set #parents to 'top-level' by default.
    $form += [
      '#parents' => [],
      '#array_parents' => [],
    ];
    $original_parents = $form['#parents'];
    $form_state = $this
      ->decorateFormState($form, $form_state);
    $this
      ->getFormEntityManager($form_state, $provided);

    // Let each widget generate the form elements.
    foreach ($this
      ->getComponents() as $name => $options) {
      $component = $this
        ->getComponentPlugin($name, $options, $form_state
        ->getFormEntityManager());

      // On each component reset the parents back to the original.
      $form['#parents'] = $original_parents;
      $component
        ->render($form, $form_state, $this->renderer);
    }

    // Set form parents back to the original.
    $form['#parents'] = $original_parents;

    // Associate the cache tags for the form display.
    $this->renderer
      ->addCacheableDependency($form, $this);

    // Add a process callback so we can assign weights and hide extra fields.
    $form['#process'][] = [
      $this,
      'processForm',
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function processForm($element, FormStateInterface $form_state, $form) {
    $element = parent::processForm($element, $form_state, $form);
    foreach ($this
      ->getFormEnhancers('process_form') as $enhancer) {
      $element = $enhancer
        ->processForm($element, $form_state, $form);
    }
    static::addSaveFormEntitiesSubmit($element, $this);
    return $element;
  }

  /**
   * {@inheritdoc}
   */
  public function extractFormValues(FieldableEntityInterface $entity, array &$form, FormStateInterface $form_state) {

    // Make sure the form entity manager is appropriately constructed.
    $extracted = [];
    $form_state = $this
      ->decorateFormState($form, $form_state);
    $this
      ->getFormEntityManager($form_state, $this
      ->getProvidedEntities($form_state, $entity), TRUE);
    foreach ($this
      ->getComponents() as $name => $options) {
      if (($component = $this
        ->getComponentPlugin($name, $options, $form_state
        ->getFormEntityManager())) && !empty($form[$name])) {
        $component
          ->extractFormValues($form[$name], $form_state);
        $extracted[$name] = $name;
      }
    }
    return $extracted;
  }

  /**
   * {@inheritdoc}
   */
  public function formValidateComponents(array $form, FormStateInterface $form_state) {
    $form_state = $this
      ->decorateFormState($form, $form_state);
    foreach ($this
      ->getComponents() as $name => $options) {
      if ($component = $this
        ->getComponentPlugin($name, $options, $form_state
        ->getFormEntityManager())) {
        if ($component instanceof FormComponentWithValidateInterface) {
          $component
            ->formValidate($form[$name], $form_state);
        }
      }
    }
  }

  /**
   * {@inheritdoc}
   */
  public function formSubmitComponents(array $form, FormStateInterface $form_state) {
    $form_state = $this
      ->decorateFormState($form, $form_state);
    foreach ($this
      ->getComponents() as $name => $options) {
      if ($component = $this
        ->getComponentPlugin($name, $options, $form_state
        ->getFormEntityManager())) {
        if ($component instanceof FormComponentWithSubmitInterface) {
          $component
            ->formSubmit($form[$name], $form_state);
        }
      }
    }
  }

  /**
   * Save the extra entities added to the form.
   */
  public function saveFormEntities(array $form, FormStateInterface $form_state) {
    $form_state = $this
      ->decorateFormState($form, $form_state);
    $form_state
      ->getFormEntityManager()
      ->saveFormEntities();
  }

  /**
   * Look through the form to find submit buttons.
   *
   * If they have the save submit method then add our saveEntities submit
   * callback.
   *
   * @param array $element
   *   The element to add the submit callback to. If this is not a submit
   *   element then continue to search the children.
   * @param \Drupal\flexiform\FlexiformEntityFormDisplayInterface $form_display
   *   The flexiform entity form display.
   *
   * @todo: Move onto the multiple_entities enhancer plugin.
   */
  public static function addSaveFormEntitiesSubmit(array &$element, FlexiformEntityFormDisplayInterface $form_display) {
    if (isset($element['#type']) && $element['#type'] == 'submit') {
      if (!empty($element['#submit']) && in_array('::save', $element['#submit'])) {
        $new_submit = [];

        // Add extra submit handlers to all buttons on the form.
        // This includes adding a formSubmitComponents callback to allow
        // components to have their own submission logic. This applies
        // BEFORE the entities are saved.
        // Also add the 'saveFormEntities' callback immediatly after the
        // standard '::save'.
        foreach ($element['#submit'] as $callback) {
          if ($callback == '::save') {
            $new_submit[] = [
              $form_display,
              'formSubmitComponents',
            ];
          }
          $new_submit[] = $callback;
          if ($callback == '::save') {
            $new_submit[] = [
              $form_display,
              'saveFormEntities',
            ];
          }
        }
        $element['#submit'] = $new_submit;
      }
      if (!empty($element['#validate'])) {

        // Add extra validate handler to all buttons on the form.
        // This allows form components to have their own validation logic.
        $element['#validate'][] = [
          $form_display,
          'formValidateComponents',
        ];
      }
    }
    else {
      foreach (Element::children($element) as $key) {
        FlexiformEntityFormDisplay::addSaveFormEntitiesSubmit($element[$key], $form_display);
      }
    }
  }

  /**
   * {@inheritdoc}
   */
  public function getFormEntityConfig() {
    $this
      ->initFormEntityConfig();
    return $this->formEntities;
  }

  /**
   * {@inheritdoc}
   */
  public function initFormEntityConfig() {
    if (empty($this->formEntities)) {
      $this->formEntities = [];
      $form_entities = [];
      foreach ($this
        ->getFormEnhancers('init_form_entity_config') as $enhancer) {
        $form_entities += $enhancer
          ->initFormEntityConfig();
      }

      // If there is a base entity add it to the configuration.
      if ($this
        ->getTargetEntityTypeId() && empty($form_entities[$this->baseEntityNamespace])) {
        $this->formEntities[$this->baseEntityNamespace] = [
          'entity_type' => $this
            ->getTargetEntityTypeId(),
          'bundle' => $this
            ->getTargetBundle(),
          'plugin' => 'provided',
          'label' => t('Base @entity_type', [
            '@entity_type' => \Drupal::service('entity_type.manager')
              ->getDefinition($this
              ->getTargetEntityTypeId())
              ->getLabel(),
          ]),
        ];
      }
      $this->formEntities += $form_entities;
    }
  }

  /**
   * Get the form entity manager.
   *
   * @param FormStateInterface $form_state
   * @param \Drupal\Core\Entity\FieldableEntityInterface[] $provided
   *   Provided entities to this entity manager.
   * @param bool $reset
   *   If TRUE always create a new form entity manager.
   *
   * @return \Drupal\flexiform\FormEntity\FlexiformFormEntityManager
   *   The form entity manager.
   */
  public function getFormEntityManager(MultipleEntityFormStateInterface $form_state, array $provided = [], $reset = FALSE) {
    $provided += $this->providedEntities;
    $this->providedEntities = $provided;
    if (!$form_state
      ->getFormEntityManager() || $reset) {
      $form_state
        ->setFormEntityManager(new FlexiformFormEntityManager($this, $provided));
    }
    return $form_state
      ->getFormEntityManager();
  }

  /**
   * Get the enhancers for this form display.
   *
   * @param string $event
   *   Optionally filter the enhancers by an applicable event.
   *
   * @return \Drupal\flexiform\FormEnhancer\FormEnhancerInterface[]
   *   An array of form enhancers/
   */
  public function getFormEnhancers($event = NULL) {
    if (empty($this->formEnhancers)) {
      $enhancer_settings = $this
        ->getThirdPartySetting('flexiform', 'enhancer', []);
      $enhancer_definitions = \Drupal::service('plugin.manager.flexiform.form_enhancer')
        ->getDefinitions();
      foreach ($enhancer_definitions as $plugin_id => $definition) {
        $this->formEnhancers[$plugin_id] = \Drupal::service('plugin.manager.flexiform.form_enhancer')
          ->createInstance($plugin_id, isset($enhancer_settings[$plugin_id]) ? $enhancer_settings[$plugin_id] : [])
          ->setFormDisplay($this);
      }
    }
    if (is_null($event)) {
      return $this->formEnhancers;
    }
    $applicable_enhancer_names = [];
    foreach ($this->formEnhancers as $plugin_id => $enhancer) {
      if (($weight = $enhancer
        ->applies($event)) !== FALSE) {
        $applicable_enhancer_names[$plugin_id] = $weight;
      }
    }
    asort($applicable_enhancer_names);
    $applicable_enhancers = [];
    foreach ($applicable_enhancer_names as $plugin_id => $weight) {
      $applicable_enhancers[$plugin_id] = $this->formEnhancers[$plugin_id];
    }
    return $applicable_enhancers;
  }

  /**
   * Get a particular form enhancer.
   *
   * @param string $enhancer_name
   *   The form enhancer name.
   *
   * @return \Drupal\flexiform\FormEnhancer\FormEnhancerInterface
   *   The form enhancer.
   */
  public function getFormEnhancer($enhancer_name) {
    if (empty($this->formEnhancers)) {
      $this
        ->getFormEnhancers();
    }
    return isset($this->formEnhancers[$enhancer_name]) ? $this->formEnhancers[$enhancer_name] : NULL;
  }

  /**
   * Get the entity form builder.
   *
   * This is designed to be helpful for enhancers that want to inspect the
   * resultant form before providing configuration options.
   *
   * @return array
   *   An array with two keys:
   *   - form_object: \Drupal\Core\Form\FormBase
   *   - form_state: \Drupal\Core\Form\FormStateInterface
   *   - form: array
   */
  public function getFormInformation() {
    $operation = $this
      ->get('originalMode') ?: $this
      ->get('mode');
    $form_object = \Drupal::service('flexiform.manager')
      ->getFormObject($this);
    $default_values = [];
    if ($bundle_key = $this
      ->entityTypeManager()
      ->getDefinition($this
      ->getTargetEntityTypeId())
      ->getKey('bundle')) {
      $default_values[$bundle_key] = $this
        ->getTargetBundle();
    }
    $form_object
      ->setEntity($this
      ->entityTypeManager()
      ->getStorage($this
      ->getTargetEntityTypeId())
      ->create($default_values));
    $form_state = new FormState();
    return [
      'form_object' => $form_object,
      'form_state' => $form_state,
      'form' => \Drupal::service('form_builder')
        ->buildForm($form_object, $form_state),
    ];
  }

  /**
   * Get the base entity namespace.
   *
   * @return string
   *   The base entity namespace.
   */
  public function getBaseEntityNamespace() {
    return $this->baseEntityNamespace;
  }

  /**
   * Decorate the form state when required.
   *
   * @param array $form
   * @param \Drupal\Core\Form\FormStateInterface $form_state
   *
   * @return \Drupal\flexiform\MultipleEntityFormStateInterface
   */
  protected function decorateFormState(array &$form, FormStateInterface $form_state) {
    return MultipleEntityFormState::createForForm($form, $form_state);
  }

}

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.
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::$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::$_core protected property Information maintained by Drupal core about configuration.
ConfigEntityBase::addDependency protected function Overrides \Drupal\Core\Entity\DependencyTrait:addDependency().
ConfigEntityBase::createDuplicate public function Creates a duplicate of the entity. Overrides EntityBase::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 EntityBase::getCacheTagsToInvalidate 1
ConfigEntityBase::getConfigDependencyName public function Gets the configuration dependency name. Overrides EntityBase::getConfigDependencyName
ConfigEntityBase::getConfigManager protected static function Gets the configuration manager.
ConfigEntityBase::getConfigTarget public function Gets the configuration target identifier for the entity. Overrides EntityBase::getConfigTarget
ConfigEntityBase::getDependencies public function Gets the configuration dependencies. Overrides ConfigEntityInterface::getDependencies
ConfigEntityBase::getOriginalId public function Gets the original ID. Overrides EntityBase::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 EntityBase::invalidateTagsOnDelete
ConfigEntityBase::invalidateTagsOnSave protected function Override to never invalidate the entity's cache tag; the config system already invalidates it. Overrides EntityBase::invalidateTagsOnSave
ConfigEntityBase::isInstallable public function Checks whether this entity is installable. Overrides ConfigEntityInterface::isInstallable 2
ConfigEntityBase::isNew public function Overrides Entity::isNew(). Overrides EntityBase::isNew
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 EntityBase::link
ConfigEntityBase::preDelete public static function Acts on entities before they are deleted and before hooks are invoked. Overrides EntityBase::preDelete 8
ConfigEntityBase::save public function Saves an entity permanently. Overrides EntityBase::save 1
ConfigEntityBase::set public function Sets the value of a property. Overrides ConfigEntityInterface::set
ConfigEntityBase::setOriginalId public function Sets the original ID. Overrides EntityBase::setOriginalId
ConfigEntityBase::setStatus public function Sets the status of the configuration entity. Overrides ConfigEntityInterface::setStatus
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 4
ConfigEntityBase::toUrl public function Gets the URL object for the entity. Overrides EntityBase::toUrl
ConfigEntityBase::trustData public function Sets that the data should be trusted. Overrides ConfigEntityInterface::trustData
ConfigEntityBase::unsetThirdPartySetting public function Unsets a third-party setting. Overrides ThirdPartySettingsInterface::unsetThirdPartySetting
ConfigEntityBase::url public function Gets the public URL for this entity. Overrides EntityBase::url
ConfigEntityBase::urlInfo public function Gets the URL object for the entity. Overrides EntityBase::urlInfo
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
DependencyTrait::$dependencies protected property The object's dependencies.
DependencyTrait::addDependencies protected function Adds multiple dependencies.
DependencyTrait::addDependency protected function Adds a dependency. Aliased as: addDependencyTrait
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::access public function Checks data value access. Overrides AccessibleInterface::access 1
EntityBase::bundle public function Gets the bundle of the entity. Overrides EntityInterface::bundle 1
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::getConfigDependencyKey public function Gets the key that is used to store configuration dependencies. Overrides EntityInterface::getConfigDependencyKey
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::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::label public function Gets the label of the entity. Overrides EntityInterface::label 6
EntityBase::language public function Gets the language of the entity. Overrides EntityInterface::language 1
EntityBase::languageManager protected function Gets the language manager.
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::postCreate public function Acts on a created entity before hooks are invoked. Overrides EntityInterface::postCreate 4
EntityBase::postDelete public static function Acts on deleted entities before the delete hook is invoked. Overrides EntityInterface::postDelete 16
EntityBase::postSave public function Acts on a saved entity before the insert or update hook is invoked. Overrides EntityInterface::postSave 14
EntityBase::preCreate public static function Changes the values of an entity before it is created. Overrides EntityInterface::preCreate 5
EntityBase::referencedEntities public function Gets a list of entities referenced by this entity. Overrides EntityInterface::referencedEntities 1
EntityBase::toLink public function Generates the HTML for a link to this entity. Overrides EntityInterface::toLink
EntityBase::uriRelationships public function Gets a list of URI relationships supported by this entity. Overrides EntityInterface::uriRelationships
EntityBase::urlRouteParameters protected function Gets an array of placeholders for this entity. 2
EntityBase::uuid public function Gets the entity UUID (Universally Unique Identifier). Overrides EntityInterface::uuid 1
EntityBase::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::$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 1
EntityDisplayBase::createCopy public function Creates a duplicate of the entity display object on a different view mode. Overrides EntityDisplayInterface::createCopy 1
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 1
EntityDisplayBase::getComponents public function Gets the display options for all components. Overrides EntityDisplayInterface::getComponents
EntityDisplayBase::getDefaultRegion protected function Gets the default region. 1
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::handleHiddenType Deprecated protected function Handles a component type of 'hidden'.
EntityDisplayBase::id public function Gets the identifier. Overrides EntityBase::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 1
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 1
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::__sleep public function Overrides ConfigEntityBase::__sleep
EntityDisplayBase::__wakeup public function Overrides DependencySerializationTrait::__wakeup
EntityFormDisplay::$displayContext protected property Context in which this entity will be used (e.g. 'view', 'form'). Overrides EntityDisplayBase::$displayContext
EntityFormDisplay::collectRenderDisplay public static function Returns the entity_form_display object used to build an entity form.
EntityFormDisplay::flagWidgetsErrorsFromViolations public function Flags entity validation violations as form errors. Overrides EntityFormDisplayInterface::flagWidgetsErrorsFromViolations
EntityFormDisplay::getPluginCollections public function Gets the plugin collections used by this object. Overrides ObjectWithPluginCollectionInterface::getPluginCollections
EntityFormDisplay::getRenderer public function Gets the renderer plugin for a field (e.g. widget, formatter). Overrides EntityDisplayInterface::getRenderer
EntityFormDisplay::movePropertyPathViolationsRelativeToField protected function Moves the property path to be relative to field level.
EntityFormDisplay::validateFormValues public function Validates submitted widget values and sets the corresponding form errors. Overrides EntityFormDisplayInterface::validateFormValues
EntityFormDisplay::__construct public function Constructs an Entity object. Overrides EntityDisplayBase::__construct
FlexiformEntityFormDisplay::$baseEntityNamespace protected property The base entity namespace.
FlexiformEntityFormDisplay::$componentTypePlugins protected property Component types.
FlexiformEntityFormDisplay::$formEnhancers protected property The form enhancers.
FlexiformEntityFormDisplay::$formEntities protected property The form entity configuration.
FlexiformEntityFormDisplay::$formEntityManager protected property The flexiform form Entity Manager.
FlexiformEntityFormDisplay::$formEntityManagerSuppliedNamespaces protected property What entities the form entity manager has been provided with.
FlexiformEntityFormDisplay::$providedEntities protected property
FlexiformEntityFormDisplay::addSaveFormEntitiesSubmit public static function Look through the form to find submit buttons.
FlexiformEntityFormDisplay::buildAdvancedForm public function Build standalone form.
FlexiformEntityFormDisplay::buildForm public function Adds field widgets to an entity form. Overrides EntityFormDisplay::buildForm
FlexiformEntityFormDisplay::collectRenderDisplayLight public static function Collect the render display for a given entity_type_id and bundle.
FlexiformEntityFormDisplay::decorateFormState protected function Decorate the form state when required.
FlexiformEntityFormDisplay::extractFormValues public function Extracts field values from the submitted widget values into the entity. Overrides EntityFormDisplay::extractFormValues
FlexiformEntityFormDisplay::formSubmitComponents public function
FlexiformEntityFormDisplay::formValidateComponents public function
FlexiformEntityFormDisplay::getBaseEntityNamespace public function Get the base entity namespace.
FlexiformEntityFormDisplay::getComponentPlugin public function Get the component plugin.
FlexiformEntityFormDisplay::getComponentTypePlugin public function Get a compoenet type plugin.
FlexiformEntityFormDisplay::getFormEnhancer public function Get a particular form enhancer.
FlexiformEntityFormDisplay::getFormEnhancers public function Get the enhancers for this form display.
FlexiformEntityFormDisplay::getFormEntityConfig public function Get the Flexiform form Entity Configuration from the object. Overrides FlexiformEntityFormDisplayInterface::getFormEntityConfig
FlexiformEntityFormDisplay::getFormEntityManager public function Get the form entity manager.
FlexiformEntityFormDisplay::getFormInformation public function Get the entity form builder.
FlexiformEntityFormDisplay::getProvidedEntities protected function Get the array of provided entities.
FlexiformEntityFormDisplay::getRegionOptions public function Returns an associative array of all regions.
FlexiformEntityFormDisplay::getRegions public function Get the regions needed to create the overview form.
FlexiformEntityFormDisplay::initFormEntityConfig public function
FlexiformEntityFormDisplay::postLoad public static function Acts on loaded entities. Overrides EntityBase::postLoad
FlexiformEntityFormDisplay::preSave public function Acts on an entity before the presave hook is invoked. Overrides EntityDisplayBase::preSave
FlexiformEntityFormDisplay::processForm public function Process callback: assigns weights and hides extra fields. Overrides EntityFormDisplay::processForm
FlexiformEntityFormDisplay::saveFormEntities public function Save the extra entities added to the form.
PluginDependencyTrait::calculatePluginDependencies protected function Calculates and adds dependencies of a specific plugin instance. 1
PluginDependencyTrait::getPluginDependencies protected function Calculates and returns dependencies of a specific plugin instance.
PluginDependencyTrait::moduleHandler protected function Wraps the module handler. 1
PluginDependencyTrait::themeHandler protected function Wraps the theme handler. 1
RefinableCacheableDependencyTrait::addCacheableDependency public function 1
RefinableCacheableDependencyTrait::addCacheContexts public function
RefinableCacheableDependencyTrait::addCacheTags public function
RefinableCacheableDependencyTrait::mergeCacheMaxAge public function
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