SimpleAccessGroupListBuilder.php in Simple Access 8.3
File
src/Controller/SimpleAccessGroupListBuilder.php
View source
<?php
namespace Drupal\simple_access\Controller;
use Drupal\Core\Config\Entity\DraggableListBuilder;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Form\FormStateInterface;
class SimpleAccessGroupListBuilder extends DraggableListBuilder {
protected $weightKey = 'weight';
public function getFormId() {
return 'simple_access_group_list';
}
public function buildHeader() {
$header = [];
$header['label'] = $this
->t('Group');
$header['roles'] = $this
->t('Roles');
return $header + parent::buildHeader();
}
public function buildRow(EntityInterface $entity) {
$row = [];
$row['label'] = $entity
->label();
$row['roles'] = [
'#type' => 'markup',
'#markup' => implode(', ', array_intersect_key(user_role_names(), array_filter($entity->roles))),
];
return $row + parent::buildRow($entity);
}
public function validateForm(array &$form, FormStateInterface $form_state) {
$form_state
->unsetValue('entities[owner][weight]');
}
}