diff --git a/core/lib/Drupal/Core/Config/Entity/DraggableListBuilder.php b/core/lib/Drupal/Core/Config/Entity/DraggableListBuilder.php index bc30674157..8571244db1 100644 --- a/core/lib/Drupal/Core/Config/Entity/DraggableListBuilder.php +++ b/core/lib/Drupal/Core/Config/Entity/DraggableListBuilder.php @@ -15,13 +15,6 @@ use DraggableListBuilderTrait; - /** - * Name of the entity's weight field or FALSE if no field is provided. - * - * @var string|bool - */ - protected $weightKey = FALSE; - /** * {@inheritdoc} */ @@ -35,7 +28,6 @@ public function __construct(EntityTypeInterface $entity_type, EntityStorageInter // Check if the entity type supports weighting. if ($this->entityType->hasKey('weight')) { - $this->hasWeight = TRUE; $this->weightKey = $this->entityType->getKey('weight'); } } diff --git a/core/lib/Drupal/Core/Entity/DraggableListBuilderTrait.php b/core/lib/Drupal/Core/Entity/DraggableListBuilderTrait.php index c51dfaa966..a915e1408b 100644 --- a/core/lib/Drupal/Core/Entity/DraggableListBuilderTrait.php +++ b/core/lib/Drupal/Core/Entity/DraggableListBuilderTrait.php @@ -24,11 +24,11 @@ protected $entities = []; /** - * Whether or not to the listed entities have a weight. + * Name of the entity's weight field or FALSE if no field is provided. * - * @var bool + * @var string|bool */ - protected $hasWeight = FALSE; + protected $weightKey = FALSE; /** * The form builder. @@ -63,7 +63,7 @@ */ public function buildHeader() { $header = []; - if ($this->hasWeight) { + if (!empty($this->weightKey)) { $header['weight'] = t('Weight'); } return $header + parent::buildHeader(); @@ -74,7 +74,7 @@ public function buildHeader() { */ public function buildRow(EntityInterface $entity) { $row = []; - if ($this->hasWeight) { + if (!empty($this->weightKey)) { // Override default values to markup elements. $row['#attributes']['class'][] = 'draggable'; $row['#weight'] = $this->getWeight($entity); @@ -94,7 +94,7 @@ public function buildRow(EntityInterface $entity) { * {@inheritdoc} */ public function render() { - if ($this->hasWeight) { + if (!empty($this->weightKey)) { return $this->formBuilder()->getForm($this); } return parent::render(); @@ -120,7 +120,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { $this->entities = $this->load(); $delta = 10; // Change the delta of the weight field if have more than 20 entities. - if ($this->hasWeight) { + if (!empty($this->weightKey)) { $count = count($this->entities); if ($count > 20) { $delta = ceil($count / 2);