protected function StringDatabaseStorage::updateLocation

Update locations for string.

Parameters

Drupal\locale\StringInterface $string: The string object.

1 call to StringDatabaseStorage::updateLocation()
StringDatabaseStorage::save in drupal/core/modules/locale/lib/Drupal/locale/StringDatabaseStorage.php
Implements Drupal\locale\StringStorageInterface::save().

File

drupal/core/modules/locale/lib/Drupal/locale/StringDatabaseStorage.php, line 144
Definition of Drupal\locale\StringDatabaseStorage.

Class

StringDatabaseStorage
Defines the locale string class.

Namespace

Drupal\locale

Code

protected function updateLocation($string) {
  if ($locations = $string
    ->getLocations(TRUE)) {
    $created = FALSE;
    foreach ($locations as $type => $location) {
      foreach ($location as $name => $lid) {
        if (!$lid) {
          $this
            ->dbDelete('locales_location', array(
            'sid' => $string
              ->getId(),
            'type' => $type,
            'name' => $name,
          ))
            ->execute();
        }
        elseif ($lid === TRUE) {

          // This is a new location to add, take care not to duplicate.
          $this->connection
            ->merge('locales_location', $this->options)
            ->key(array(
            'sid' => $string
              ->getId(),
            'type' => $type,
            'name' => $name,
          ))
            ->fields(array(
            'version' => VERSION,
          ))
            ->execute();
          $created = TRUE;
        }

        // Loaded locations have 'lid' integer value, nor FALSE, nor TRUE.
      }
    }
    if ($created) {

      // As we've set a new location, check string version too.
      $this
        ->checkVersion($string, VERSION);
    }
  }
}