You are here

function lingotek_update_8205 in Lingotek Translation 8.2

Set the default filter for existing profiles and settings.

File

./lingotek.install, line 492
Install, update and uninstall functions for the Lingotek module.

Code

function lingotek_update_8205() {
  $config_factory = \Drupal::configFactory();
  $config = $config_factory
    ->getEditable('lingotek.settings');
  $config
    ->set('default.filter', 'project_default');
  $config
    ->set('default.subfilter', 'project_default');
  $config
    ->set('account.resources.filter', []);
  $config
    ->save();

  /** @var \Drupal\lingotek\Entity\LingotekProfile $profiles */
  $profiles = LingotekProfile::loadMultiple();
  foreach ($profiles as $id => $profile) {
    $profile
      ->setFilter('project_default');
    $profile
      ->setSubfilter('project_default');
    $profile
      ->save();
  }
}