You are here

function entityqueue_update_8001 in Entityqueue 8

Updates the internal structure of the entity queue config entities.

File

./entityqueue.install, line 14
Install, update and uninstall functions for the Entityqueue module.

Code

function entityqueue_update_8001() {
  $config_factory = \Drupal::configFactory();

  // Iterate over all entity queues.
  foreach ($config_factory
    ->listAll('entityqueue.entity_queue.') as $queue_id) {
    $config = $config_factory
      ->getEditable($queue_id);
    $entity_settings = [
      'target_type' => $config
        ->get('target_type'),
      'handler' => 'default:' . $config
        ->get('target_type'),
      'handler_settings' => [],
    ];
    $config
      ->set('entity_settings', $entity_settings);
    $queue_settings = [
      'min_size' => $config
        ->get('min_size'),
      'max_size' => $config
        ->get('max_size'),
      'act_as_queue' => $config
        ->get('act_as_queue'),
    ];
    $config
      ->set('queue_settings', $queue_settings);

    // Remove outdated properties.
    $config
      ->clear('min_size')
      ->clear('max_size')
      ->clear('act_as_queue')
      ->clear('target_type');
    $config
      ->save(TRUE);
  }
}