comparison core/modules/user/src/RoleListBuilder.php @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents 4c8ae668cc8c
children af1871eacc83
comparison
equal deleted inserted replaced
16:c2387f117808 17:129ea1e6d783
2 2
3 namespace Drupal\user; 3 namespace Drupal\user;
4 4
5 use Drupal\Core\Config\Entity\DraggableListBuilder; 5 use Drupal\Core\Config\Entity\DraggableListBuilder;
6 use Drupal\Core\Entity\EntityInterface; 6 use Drupal\Core\Entity\EntityInterface;
7 use Drupal\Core\Entity\EntityStorageInterface;
8 use Drupal\Core\Entity\EntityTypeInterface;
7 use Drupal\Core\Form\FormStateInterface; 9 use Drupal\Core\Form\FormStateInterface;
10 use Drupal\Core\Messenger\MessengerInterface;
11 use Symfony\Component\DependencyInjection\ContainerInterface;
8 12
9 /** 13 /**
10 * Defines a class to build a listing of user role entities. 14 * Defines a class to build a listing of user role entities.
11 * 15 *
12 * @see \Drupal\user\Entity\Role 16 * @see \Drupal\user\Entity\Role
13 */ 17 */
14 class RoleListBuilder extends DraggableListBuilder { 18 class RoleListBuilder extends DraggableListBuilder {
19
20 /**
21 * The messenger.
22 *
23 * @var \Drupal\Core\Messenger\MessengerInterface
24 */
25 protected $messenger;
26
27 /**
28 * RoleListBuilder constructor.
29 *
30 * @param \Drupal\Core\Entity\EntityTypeInterface $entityType
31 * The entity type definition.
32 * @param \Drupal\Core\Entity\EntityStorageInterface $storage
33 * The entity storage class.
34 * @param \Drupal\Core\Messenger\MessengerInterface $messenger
35 * The messenger.
36 */
37 public function __construct(EntityTypeInterface $entityType,
38 EntityStorageInterface $storage,
39 MessengerInterface $messenger) {
40 parent::__construct($entityType, $storage);
41 $this->messenger = $messenger;
42 }
43
44 /**
45 * {@inheritdoc}
46 */
47 public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
48 return new static(
49 $entity_type,
50 $container->get('entity.manager')->getStorage($entity_type->id()),
51 $container->get('messenger')
52 );
53 }
15 54
16 /** 55 /**
17 * {@inheritdoc} 56 * {@inheritdoc}
18 */ 57 */
19 public function getFormId() { 58 public function getFormId() {
56 * {@inheritdoc} 95 * {@inheritdoc}
57 */ 96 */
58 public function submitForm(array &$form, FormStateInterface $form_state) { 97 public function submitForm(array &$form, FormStateInterface $form_state) {
59 parent::submitForm($form, $form_state); 98 parent::submitForm($form, $form_state);
60 99
61 drupal_set_message(t('The role settings have been updated.')); 100 $this->messenger->addStatus($this->t('The role settings have been updated.'));
62 } 101 }
63 102
64 } 103 }