diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php index ab2fb10..1047302 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php @@ -197,7 +197,8 @@ public function disable() { * {@inheritdoc} */ public function setStatus($status) { - $this->status = (bool) $status; + $status_key = $this->getEntityType()->getKey('status'); + $this->{$status_key} = (bool) $status; return $this; } @@ -205,7 +206,8 @@ public function setStatus($status) { * {@inheritdoc} */ public function status() { - return !empty($this->status); + $status_key = $this->getEntityType()->getKey('status'); + return $status_key && !empty($this->{$status_key}); } /** @@ -253,13 +255,20 @@ public function createDuplicate() { * Helper callback for uasort() to sort configuration entities by weight and label. */ public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b) { - $a_weight = isset($a->weight) ? $a->weight : 0; - $b_weight = isset($b->weight) ? $b->weight : 0; - if ($a_weight == $b_weight) { - $a_label = $a->label(); - $b_label = $b->label(); - return strnatcasecmp($a_label, $b_label); + $entity_type = $a->getEntityType(); + if ($entity_type->hasKey('weight')) { + $weight_key = $entity_type->getKey('weight'); + $a_weight = isset($a->{$weight_key}) ? $a->{$weight_key} : 0; + $b_weight = isset($b->{$weight_key}) ? $b->{$weight_key} : 0; } + else { + $a_weight = $b_weight = 0; + } + + if ($a_weight == $b_weight) { + return strnatcasecmp($a->label(), $b->label()); + } + return ($a_weight < $b_weight) ? -1 : 1; } diff --git a/core/lib/Drupal/Core/Entity/Entity.php b/core/lib/Drupal/Core/Entity/Entity.php index 2a4b199..3abb33e 100644 --- a/core/lib/Drupal/Core/Entity/Entity.php +++ b/core/lib/Drupal/Core/Entity/Entity.php @@ -99,7 +99,8 @@ protected function uuidGenerator() { * {@inheritdoc} */ public function id() { - return isset($this->id) ? $this->id : NULL; + $id_key = $this->getEntityType()->getKey('id'); + return isset($this->{$id_key}) ? $this->{$id_key} : NULL; } /** diff --git a/core/modules/block/src/Entity/Block.php b/core/modules/block/src/Entity/Block.php index 8a65843..ee70a56 100644 --- a/core/modules/block/src/Entity/Block.php +++ b/core/modules/block/src/Entity/Block.php @@ -33,7 +33,8 @@ * }, * admin_permission = "administer blocks", * entity_keys = { - * "id" = "id" + * "id" = "id", + * "status" = "status", * }, * links = { * "delete-form" = "/admin/structure/block/manage/{block}/delete",