function opigno_group_manager_update_8007 in Opigno group manager 8
Content relationship cleanup.
File
- ./
opigno_group_manager.install, line 109 - Opigno group manager install/update functionality.
Code
function opigno_group_manager_update_8007() {
$query = \Drupal::database()
->select('opigno_group_content', 'op')
->fields('op', [
'id',
]);
$query
->leftJoin('groups', 'g', 'op.group_id = g.id');
$query
->where('isnull(g.id) = :condition', [
':condition' => TRUE,
]);
$ids = $query
->execute()
->fetchCol();
/* @var \Drupal\opigno_group_manager\Entity\OpignoGroupManagedContent[] $opigno_group_managed_contents */
$opigno_group_managed_contents = OpignoGroupManagedContent::loadMultiple($ids);
foreach ($opigno_group_managed_contents as $opigno_group_managed_content) {
$opigno_group_managed_content
->delete();
}
}