-
-
Save damiankloip/0952d27467c757acb51c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/core/lib/Drupal/Core/Entity/Entity.php b/core/lib/Drupal/Core/Entity/Entity.php | |
index cf18d55..0b47db2 100644 | |
--- a/core/lib/Drupal/Core/Entity/Entity.php | |
+++ b/core/lib/Drupal/Core/Entity/Entity.php | |
@@ -135,7 +135,14 @@ public function bundle() { | |
public function label() { | |
$label = NULL; | |
$entity_type = $this->getEntityType(); | |
- if (($label_callback = $entity_type->getLabelCallback()) && is_callable($label_callback)) { | |
+ $label_callback = $entity_type->getLabelCallback(); | |
+ | |
+ // If the callback starts with '::' assume it is a method on the entity. | |
+ if ($label_callback && strpos($label_callback, '::') === 0) { | |
+ $label_callback = array($this, str_replace('::', '', $label_callback)); | |
+ } | |
+ | |
+ if ($label_callback && is_callable($label_callback)) { | |
$label = call_user_func($label_callback, $this); | |
} | |
elseif (($label_key = $entity_type->getKey('label')) && isset($this->{$label_key})) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment