class RoleListBuilder
Same name and namespace in other branches
- 11.x core/modules/user/src/RoleListBuilder.php \Drupal\user\RoleListBuilder
- 10 core/modules/user/src/RoleListBuilder.php \Drupal\user\RoleListBuilder
- 8.9.x core/modules/user/src/RoleListBuilder.php \Drupal\user\RoleListBuilder
Defines a class to build a listing of user role entities.
Hierarchy
- class \Drupal\Core\Entity\EntityHandlerBase uses \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait
- class \Drupal\Core\Entity\EntityListBuilder implements \Drupal\Core\Entity\EntityListBuilderInterface, \Drupal\Core\Entity\EntityHandlerInterface uses \Drupal\Core\Messenger\MessengerTrait, \Drupal\Core\Routing\RedirectDestinationTrait extends \Drupal\Core\Entity\EntityHandlerBase
- class \Drupal\Core\Config\Entity\ConfigEntityListBuilder extends \Drupal\Core\Entity\EntityListBuilder
- class \Drupal\Core\Config\Entity\DraggableListBuilder implements \Drupal\Core\Form\FormInterface extends \Drupal\Core\Config\Entity\ConfigEntityListBuilder
- class \Drupal\user\RoleListBuilder extends \Drupal\Core\Config\Entity\DraggableListBuilder
- class \Drupal\Core\Config\Entity\DraggableListBuilder implements \Drupal\Core\Form\FormInterface extends \Drupal\Core\Config\Entity\ConfigEntityListBuilder
- class \Drupal\Core\Config\Entity\ConfigEntityListBuilder extends \Drupal\Core\Entity\EntityListBuilder
- class \Drupal\Core\Entity\EntityListBuilder implements \Drupal\Core\Entity\EntityListBuilderInterface, \Drupal\Core\Entity\EntityHandlerInterface uses \Drupal\Core\Messenger\MessengerTrait, \Drupal\Core\Routing\RedirectDestinationTrait extends \Drupal\Core\Entity\EntityHandlerBase
Expanded class hierarchy of RoleListBuilder
See also
File
-
core/
modules/ user/ src/ RoleListBuilder.php, line 18
Namespace
Drupal\userView source
class RoleListBuilder extends DraggableListBuilder {
/**
* The messenger.
*
* @var \Drupal\Core\Messenger\MessengerInterface
*/
protected $messenger;
/**
* RoleListBuilder constructor.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entityType
* The entity type definition.
* @param \Drupal\Core\Entity\EntityStorageInterface $storage
* The entity storage class.
* @param \Drupal\Core\Messenger\MessengerInterface $messenger
* The messenger.
*/
public function __construct(EntityTypeInterface $entityType, EntityStorageInterface $storage, MessengerInterface $messenger) {
parent::__construct($entityType, $storage);
$this->messenger = $messenger;
}
/**
* {@inheritdoc}
*/
public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
return new static($entity_type, $container->get('entity_type.manager')
->getStorage($entity_type->id()), $container->get('messenger'));
}
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'user_admin_roles_form';
}
/**
* {@inheritdoc}
*/
public function buildHeader() {
$header['label'] = t('Name');
return $header + parent::buildHeader();
}
/**
* {@inheritdoc}
*/
public function buildRow(EntityInterface $entity) {
$row['label'] = $entity->label();
return $row + parent::buildRow($entity);
}
/**
* {@inheritdoc}
*/
public function getDefaultOperations(EntityInterface $entity) {
$operations = parent::getDefaultOperations($entity);
if ($entity->hasLinkTemplate('edit-permissions-form')) {
$operations['permissions'] = [
'title' => t('Edit permissions'),
'weight' => 20,
'url' => $entity->toUrl('edit-permissions-form'),
];
}
return $operations;
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
parent::submitForm($form, $form_state);
$this->messenger
->addStatus($this->t('The role settings have been updated.'));
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.