getEntitiesByClass example


  protected function postLoad(array &$entities) {
    $entities_by_class = $this->getEntitiesByClass($entities);

    // Invoke entity class specific postLoad() methods. If there's only a single     // class involved, we want to pass in the original $entities array. For     // example, to provide backwards compatibility with the legacy behavior of     // the deprecated user_roles() method, \Drupal\user\Entity\Role::postLoad()     // sorts the array to enforce role weights. We have to let it manipulate the     // final array, not a subarray. However if there are multiple bundle classes     // involved, we only want to pass each one the entities that match.     if (count($entities_by_class) === 1) {
      $entity_class = array_key_first($entities_by_class);
      $entity_class::postLoad($this$entities);
    }
Home | Imprint | This part of the site doesn't use cookies.