
| Current Path : /var/www/html/rocksensor3/web/core/lib/Drupal/Core/Config/Entity/ |
Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 |
| Current File : /var/www/html/rocksensor3/web/core/lib/Drupal/Core/Config/Entity/DraggableListBuilder.php |
<?php
namespace Drupal\Core\Config\Entity;
use Drupal\Core\Entity\DraggableListBuilderTrait;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Form\FormInterface;
/**
* Defines a class to build a draggable listing of configuration entities.
*/
abstract class DraggableListBuilder extends ConfigEntityListBuilder implements FormInterface {
use DraggableListBuilderTrait;
/**
* {@inheritdoc}
*/
public function __construct(EntityTypeInterface $entity_type, EntityStorageInterface $storage) {
parent::__construct($entity_type, $storage);
// Do not inject the form builder for backwards-compatibility.
$this->formBuilder = \Drupal::formBuilder();
// Check if the entity type supports weighting.
if ($this->entityType->hasKey('weight')) {
$this->weightKey = $this->entityType->getKey('weight');
}
$this->limit = FALSE;
}
/**
* {@inheritdoc}
*/
protected function getWeight(EntityInterface $entity): int|float {
/** @var \Drupal\Core\Config\Entity\ConfigEntityInterface $entity */
return $entity->get($this->weightKey) ?: 0;
}
/**
* {@inheritdoc}
*/
protected function setWeight(EntityInterface $entity, int|float $weight): EntityInterface {
/** @var \Drupal\Core\Config\Entity\ConfigEntityInterface $entity */
$entity->set($this->weightKey, $weight);
return $entity;
}
}