You are here

public function RegistrantsElementUtility::identityExists in RNG - Events and Registrations 3.x

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

Determine if an identity is already used.

Parameters

\Drupal\Core\Entity\EntityInterface $identity: An identity to check.

Return value

bool Whether the identity is already used.

1 call to RegistrantsElementUtility::identityExists()
RegistrantsElementUtility::peopleTypeOptions in src/RegistrantsElementUtility.php
Generate available people type options suitable for radios element.

File

src/RegistrantsElementUtility.php, line 264

Class

RegistrantsElementUtility

Namespace

Drupal\rng

Code

public function identityExists(EntityInterface $identity) {
  $registrants = $this
    ->getRegistrants();
  foreach ($registrants as $registrant) {
    if ($registrant
      ->getIdentity() && $registrant
      ->getIdentity()
      ->id() == $identity
      ->id() && $registrant
      ->getIdentity()
      ->getEntityTypeId() == $identity
      ->getEntityTypeId()) {
      return TRUE;
    }
  }
  return FALSE;
}