You are here

public function YamlFormEntityListBuilder::load in YAML Form 8

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

src/YamlFormEntityListBuilder.php, line 306

Class

YamlFormEntityListBuilder
Defines a class to build a listing of form entities.

Namespace

Drupal\yamlform

Code

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

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

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