You are here

public function WebformAccessGroupListBuilder::load in Webform 6.x

Same name and namespace in other branches
  1. 8.5 modules/webform_access/src/WebformAccessGroupListBuilder.php \Drupal\webform_access\WebformAccessGroupListBuilder::load()

Loads entities of this type from storage for listing.

This allows the implementation to manipulate the listing, like filtering or sorting the loaded entities.

Return value

\Drupal\Core\Entity\EntityInterface[] An array of entities implementing \Drupal\Core\Entity\EntityInterface indexed by their IDs. Returns an empty array if no matching entities are found.

Overrides ConfigEntityListBuilder::load

File

modules/webform_access/src/WebformAccessGroupListBuilder.php, line 232

Class

WebformAccessGroupListBuilder
Defines a class to build a listing of webform access group entities.

Namespace

Drupal\webform_access

Code

public function load() {
  $entity_ids = $this
    ->getEntityIds();

  /* @var $entities \Drupal\webform\WebformInterface[] */
  $entities = $this->storage
    ->loadMultiple($entity_ids);

  // If the user is not a webform admin, check access to each access group.
  if (!$this->currentUser
    ->hasPermission('administer webform')) {
    foreach ($entities as $entity_id => $entity) {
      if (!$entity
        ->access('update', $this->currentUser)) {
        unset($entities[$entity_id]);
      }
    }
  }
  return $entities;
}