diff --git a/core/modules/entity/lib/Drupal/entity/EntityDisplayModeBase.php b/core/modules/entity/lib/Drupal/entity/EntityDisplayModeBase.php index 57b37cb..c586d54 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->getTargetEntityTypeId(); + $b_type = $b->getTargetEntityTypeId(); $type_order = strnatcasecmp($a_type, $b_type); return $type_order != 0 ? $type_order : parent::sort($a, $b); } @@ -75,16 +75,32 @@ public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b) /** * {@inheritdoc} */ - public function getTargetType() { + public function getTargetEntityTypeId() { return $this->targetEntityType; } /** * {@inheritdoc} */ + public function setTargetEntityTypeId($target_entity_type_id) { + $this->set('targetEntityType', $target_entity_type_id); + 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); + $target_entity_type = \Drupal::entityManager()->getDefinition($this->getTargetEntityTypeId()); $this->addDependency('module', $target_entity_type->getProvider()); return $this->dependencies; } diff --git a/core/modules/entity/lib/Drupal/entity/EntityDisplayModeInterface.php b/core/modules/entity/lib/Drupal/entity/EntityDisplayModeInterface.php index 178df61..cf03260 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 getTargetEntityTypeId(); + + /** + * Sets the target entity type to be displayed. + * + * @param string target_entity_type_id + * The entity type to be displayed. + * + * @return $this + */ + public function setTargetEntityTypeId($target_entity_type_id); + + /** + * Sets the label. + * + * @param string $label + * The label to be set for the display mode. + * + * @return $this + */ + public function setLabel($label); } diff --git a/core/modules/entity/lib/Drupal/entity/EntityDisplayModeListBuilder.php b/core/modules/entity/lib/Drupal/entity/EntityDisplayModeListBuilder.php index 05c241a..e517436 100644 --- a/core/modules/entity/lib/Drupal/entity/EntityDisplayModeListBuilder.php +++ b/core/modules/entity/lib/Drupal/entity/EntityDisplayModeListBuilder.php @@ -77,7 +77,7 @@ public function buildRow(EntityInterface $entity) { public function load() { $entities = array(); foreach (parent::load() as $entity) { - $entities[$entity->getTargetType()][] = $entity; + $entities[$entity->getTargetTypeId()][] = $entity; } return $entities; } 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_.]+',