You are here

function opigno_module_update_8024 in Opigno module 8

Fix issue with mandatory field for Opigno Module.

File

./opigno_module.install, line 1378
Opigno module app install/update functionality.

Code

function opigno_module_update_8024() {
  $moduleHandler = \Drupal::service('module_handler');
  if (!$moduleHandler
    ->moduleExists('opigno_skills_system')) {
    return;
  }

  // Get issue Opigno Module entities.
  $issue_modules = \Drupal::entityQuery('opigno_module')
    ->condition('skills_active', NULL, 'IS NULL')
    ->execute();
  if (!empty($issue_modules)) {
    $modules = \Drupal::entityTypeManager()
      ->getStorage('opigno_module')
      ->loadMultiple($issue_modules);

    // Update "skills_active" field.
    foreach ($modules as $module) {

      /* @var \Drupal\opigno_module\Entity\OpignoModule $module */
      $module
        ->set('skills_active', 0);
      $module
        ->save();
    }
  }
}