You are here

protected function EventMeta::countRngReferenceableEntities in RNG - Events and Registrations 8.2

Same name and namespace in other branches
  1. 8 src/EventMeta.php \Drupal\rng\EventMeta::countRngReferenceableEntities()
  2. 3.x src/EventMeta.php \Drupal\rng\EventMeta::countRngReferenceableEntities()

Count referencable entities using a rng_register entity selection plugin.

Parameters

string $entity_type_id: An identity entity type ID.

array $bundles: (optional) An array of bundles.

Return value

int The number of referencable entities.

2 calls to EventMeta::countRngReferenceableEntities()
EventMeta::canRegisterProxyIdentities in src/EventMeta.php
Determine if the current user has proxy register access.
EventMeta::countProxyIdentities in src/EventMeta.php
Count number of identities the current user has proxy register access.

File

src/EventMeta.php, line 536

Class

EventMeta
Meta event wrapper for RNG.

Namespace

Drupal\rng

Code

protected function countRngReferenceableEntities($entity_type_id, $bundles = []) {
  $selection_groups = $this->selectionPluginManager
    ->getSelectionGroups($entity_type_id);
  if (isset($selection_groups['rng_register'])) {
    $options = [
      'target_type' => $entity_type_id,
      'handler' => 'rng_register',
      'handler_settings' => [
        'event_entity_type' => $this
          ->getEvent()
          ->getEntityTypeId(),
        'event_entity_id' => $this
          ->getEvent()
          ->id(),
      ],
    ];
    if (!empty($bundles)) {
      $options['handler_settings']['target_bundles'] = $bundles;
    }
    return $this->selectionPluginManager
      ->getInstance($options)
      ->countReferenceableEntities();
  }
  return 0;
}