public function Registration::addIdentity in RNG - Events and Registrations 8
Same name and namespace in other branches
- 8.2 src/Entity/Registration.php \Drupal\rng\Entity\Registration::addIdentity()
- 3.x src/Entity/Registration.php \Drupal\rng\Entity\Registration::addIdentity()
Shortcut to add a registrant entity.
Take care to ensure the identity is not already on the registration.
Parameters
\Drupal\Core\Entity\EntityInterface $identity: The identity to add.
Return value
\Drupal\rng\RegistrationInterface Returns registration for chaining.
Overrides RegistrationInterface::addIdentity
File
- src/
Entity/ Registration.php, line 150
Class
- Registration
- Defines the registration entity class.
Namespace
Drupal\rng\EntityCode
public function addIdentity(EntityInterface $identity) {
if ($this
->hasIdentity($identity)) {
// Identity already exists on this registration.
throw new \Exception('Duplicate identity on registration');
}
$this->identities_unsaved[] = $identity;
return $this;
}