public function Registration::addGroup in RNG - Events and Registrations 3.x
Same name and namespace in other branches
- 8.2 src/Entity/Registration.php \Drupal\rng\Entity\Registration::addGroup()
- 8 src/Entity/Registration.php \Drupal\rng\Entity\Registration::addGroup()
Add a group to the registration.
Parameters
\Drupal\rng\Entity\GroupInterface $group: The group to add.
Return value
\Drupal\rng\Entity\RegistrationInterface Returns registration for chaining.
Overrides RegistrationInterface::addGroup
1 call to Registration::addGroup()
- Registration::preSave in src/
Entity/ Registration.php - Acts on an entity before the presave hook is invoked.
File
- src/
Entity/ Registration.php, line 263
Class
- Registration
- Defines the registration entity class.
Namespace
Drupal\rng\EntityCode
public function addGroup(GroupInterface $group) {
// Do not add the group if it is already related.
if (!in_array($group, $this
->getGroups())) {
if ($group
->getEvent() != $this
->getEvent()) {
throw new \Exception('Group and registration events do not match.');
}
$this->groups
->appendItem($group);
}
return $this;
}