public function GroupTypeManager::removeGroup in Organic groups 8
Removes an entity type instance as being an OG group.
Overrides GroupTypeManagerInterface::removeGroup
File
- src/
GroupTypeManager.php, line 291
Class
- GroupTypeManager
- A manager to keep track of which entity type/bundles are OG group enabled.
Namespace
Drupal\ogCode
public function removeGroup($entity_type_id, $bundle_id) {
$editable = $this->configFactory
->getEditable('og.settings');
$groups = $editable
->get('groups');
if (isset($groups[$entity_type_id])) {
$search_key = array_search($bundle_id, $groups[$entity_type_id]);
if ($search_key !== FALSE) {
unset($groups[$entity_type_id][$search_key]);
}
// Clean up entity types that have become empty.
$groups = array_filter($groups);
// Only update and refresh the map if a key was found and unset.
$editable
->set('groups', $groups);
$editable
->save();
$this
->resetGroupMap();
// Routes will need to be rebuilt.
$this->routeBuilder
->setRebuildNeeded();
}
}