You are here

protected function RngEventType::getIdentityTypeKey in RNG - Events and Registrations 3.x

Same name and namespace in other branches
  1. 8.2 src/Entity/RngEventType.php \Drupal\rng\Entity\RngEventType::getIdentityTypeKey()

Get the array key of the people type.

Parameters

string $entity_type: The identity entity type ID.

string $bundle: The identity bundle.

bool $create_key: Will initialise the array key.

Return value

int|false The array key, or FALSE if it does not exist.

6 calls to RngEventType::getIdentityTypeKey()
RngEventType::canIdentityTypeCreate in src/Entity/RngEventType.php
Whether a identity type can be created.
RngEventType::canIdentityTypeReference in src/Entity/RngEventType.php
Whether an existing identity type can be referenced.
RngEventType::getIdentityTypeEntityFormMode in src/Entity/RngEventType.php
Get the form display mode used when the identity is created inline.
RngEventType::setIdentityTypeCreate in src/Entity/RngEventType.php
Set whether an identity type can be created.
RngEventType::setIdentityTypeEntityFormMode in src/Entity/RngEventType.php
Set the form display mode used when the identity is created inline.

... See full list

File

src/Entity/RngEventType.php, line 328

Class

RngEventType
Defines the event type entity.

Namespace

Drupal\rng\Entity

Code

protected function getIdentityTypeKey($entity_type, $bundle, $create_key = TRUE) {
  if (isset($this->people_types)) {
    $pairs = $this->people_types;
    foreach ($pairs as $k => $pair) {
      if ($pair['entity_type'] == $entity_type && $pair['bundle'] == $bundle) {
        return $k;
      }
    }
  }
  if ($create_key) {

    // Create if it doesn't exist.
    $next_key = count($this->people_types) + 1;
    $this->people_types[$next_key] = [
      'entity_type' => $entity_type,
      'bundle' => $bundle,
    ];
    return $next_key;
  }
  return FALSE;
}