diff --git a/core/modules/entity/lib/Drupal/entity/EntityDisplayModeBase.php b/core/modules/entity/lib/Drupal/entity/EntityDisplayModeBase.php index a5c9909..ddeda0d 100644 --- a/core/modules/entity/lib/Drupal/entity/EntityDisplayModeBase.php +++ b/core/modules/entity/lib/Drupal/entity/EntityDisplayModeBase.php @@ -66,8 +66,8 @@ public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b) /** @var \Drupal\entity\EntityDisplayModeInterface $a */ /** @var \Drupal\entity\EntityDisplayModeInterface $b */ // Sort by the type of entity the view mode is used for. - $a_type = $a->getTargetType(); - $b_type = $b->getTargetType(); + $a_type = $a->getTargetTypeId(); + $b_type = $b->getTargetTypeId(); $type_order = strnatcasecmp($a_type, $b_type); return $type_order != 0 ? $type_order : parent::sort($a, $b); } @@ -75,13 +75,29 @@ public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b) /** * {@inheritdoc} */ - public function getTargetType() { + public function getTargetTypeId() { return $this->targetEntityType; } /** * {@inheritdoc} */ + public function setTargetTypeId($target_type) { + $this->set('targetEntityType', $target_type); + return $this; + } + + /** + * {@inheritdoc} + */ + public function setLabel($label) { + $this->set('label', $label); + return $this; + } + + /** + * {@inheritdoc} + */ public function calculateDependencies() { parent::calculateDependencies(); $target_entity_type = \Drupal::entityManager()->getDefinition($this->targetEntityType); diff --git a/core/modules/entity/lib/Drupal/entity/EntityDisplayModeInterface.php b/core/modules/entity/lib/Drupal/entity/EntityDisplayModeInterface.php index 178df61..83e34b9 100644 --- a/core/modules/entity/lib/Drupal/entity/EntityDisplayModeInterface.php +++ b/core/modules/entity/lib/Drupal/entity/EntityDisplayModeInterface.php @@ -20,6 +20,26 @@ * @return string * The entity type name. */ - public function getTargetType(); + public function getTargetTypeId(); + + /** + * Sets the target entity type to be displayed. + * + * @param string target_type + * The entity type that this EntityView is for. + * + * @return this + */ + public function setTargetTypeId($target_type); + + /** + * Sets the label. + * + * @param string $label + * The label to be set for the view mode. + * + * @return this + */ + public function setLabel($label); } diff --git a/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeFormBase.php b/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeFormBase.php index 4247502..3f1a9a8 100644 --- a/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeFormBase.php +++ b/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeFormBase.php @@ -85,7 +85,7 @@ public function form(array $form, array &$form_state) { '#description' => t('A unique machine-readable name. Can only contain lowercase letters, numbers, and underscores.'), '#disabled' => !$this->entity->isNew(), '#default_value' => $this->entity->id(), - '#field_prefix' => $this->entity->isNew() ? $this->entity->getTargetType() . '.' : '', + '#field_prefix' => $this->entity->isNew() ? $this->entity->getTargetTypeId() . '.' : '', '#machine_name' => array( 'exists' => array($this, 'exists'), 'replace_pattern' => '[^a-z0-9_.]+',