You are here

public function EventMeta::identitiesCanRegister in RNG - Events and Registrations 3.x

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

Determine if identities can register.

Parameters

string $entity_type: An identity entity type ID.

int[] $entity_ids: An array of identity entity IDs.

Return value

integer[] An array of ID's of the identities that can register.

Overrides EventMetaInterface::identitiesCanRegister

File

src/EventMeta.php, line 614

Class

EventMeta
Meta event wrapper for RNG.

Namespace

Drupal\rng

Code

public function identitiesCanRegister($entity_type, array $entity_ids) {
  $identity_types = $this
    ->getIdentityTypes();
  if (isset($identity_types[$entity_type])) {
    $options = [
      'target_type' => $entity_type,
      'handler' => 'rng_register',
      'handler_settings' => [
        'event_entity_type' => $this
          ->getEvent()
          ->getEntityTypeId(),
        'event_entity_id' => $this
          ->getEvent()
          ->id(),
      ],
    ];
    if ($this
      ->entityTypeHasBundles($entity_type)) {
      $options['handler_settings']['target_bundles'] = $identity_types[$entity_type];
    }

    /* @var $selection \Drupal\Core\Entity\EntityReferenceSelection\SelectionInterface */
    $selection = $this->selectionPluginManager
      ->getInstance($options);
    return $selection
      ->validateReferenceableEntities($entity_ids);
  }
  return [];
}