You are here

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

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

Removes references to a default group from the event.

Parameters

int $group_id: The ID of a registration_group entity.

Return value

\Drupal\Core\Entity\EntityInterface The modified event.

Overrides EventMetaInterface::removeGroup

File

src/EventMeta.php, line 222

Class

EventMeta
Meta event wrapper for RNG.

Namespace

Drupal\rng

Code

public function removeGroup($group_id) {

  /** @var \Drupal\Core\Field\FieldItemListInterface $groups */
  $groups =& $this->entity->{EventManagerInterface::FIELD_REGISTRATION_GROUPS};
  foreach ($groups
    ->getValue() as $key => $value) {
    if ($value['target_id'] == $group_id) {
      $groups
        ->removeItem($key);
    }
  }
  return $this->entity;
}