Mercurial > hg > cmmr2012-drupal-site
comparison core/modules/locale/tests/src/Functional/LocaleUpdateBase.php @ 5:12f9dff5fda9 tip
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:34:47 +0100 |
parents | a9cd425dd02b |
children |
comparison
equal
deleted
inserted
replaced
4:a9cd425dd02b | 5:12f9dff5fda9 |
---|---|
1 <?php | 1 <?php |
2 | 2 |
3 namespace Drupal\Tests\locale\Functional; | 3 namespace Drupal\Tests\locale\Functional; |
4 | 4 |
5 use Drupal\Core\Database\Database; | |
6 use Drupal\Core\File\FileSystemInterface; | |
5 use Drupal\Core\StreamWrapper\PublicStream; | 7 use Drupal\Core\StreamWrapper\PublicStream; |
6 use Drupal\file\Entity\File; | 8 use Drupal\file\Entity\File; |
7 use Drupal\Tests\BrowserTestBase; | 9 use Drupal\Tests\BrowserTestBase; |
8 use Drupal\Component\Render\FormattableMarkup; | 10 use Drupal\Component\Render\FormattableMarkup; |
9 | 11 |
73 * @param string $path | 75 * @param string $path |
74 * Path of the translations directory relative to the drupal installation | 76 * Path of the translations directory relative to the drupal installation |
75 * directory. | 77 * directory. |
76 */ | 78 */ |
77 protected function setTranslationsDirectory($path) { | 79 protected function setTranslationsDirectory($path) { |
78 file_prepare_directory($path, FILE_CREATE_DIRECTORY); | 80 \Drupal::service('file_system')->prepareDirectory($path, FileSystemInterface::CREATE_DIRECTORY); |
79 $this->config('locale.settings')->set('translation.path', $path)->save(); | 81 $this->config('locale.settings')->set('translation.path', $path)->save(); |
80 } | 82 } |
81 | 83 |
82 /** | 84 /** |
83 * Adds a language. | 85 * Adds a language. |
127 $text .= 'msgid "' . $source . '"' . "\n"; | 129 $text .= 'msgid "' . $source . '"' . "\n"; |
128 $text .= 'msgstr "' . $target . '"' . "\n"; | 130 $text .= 'msgstr "' . $target . '"' . "\n"; |
129 } | 131 } |
130 } | 132 } |
131 | 133 |
132 file_prepare_directory($path, FILE_CREATE_DIRECTORY); | 134 \Drupal::service('file_system')->prepareDirectory($path, FileSystemInterface::CREATE_DIRECTORY); |
133 $file = File::create([ | 135 $file = File::create([ |
134 'uid' => 1, | 136 'uid' => 1, |
135 'filename' => $filename, | 137 'filename' => $filename, |
136 'uri' => $path . '/' . $filename, | 138 'uri' => $path . '/' . $filename, |
137 'filemime' => 'text/x-gettext-translation', | 139 'filemime' => 'text/x-gettext-translation', |
276 $data[] = [ | 278 $data[] = [ |
277 'project' => 'custom_module_one', | 279 'project' => 'custom_module_one', |
278 'filename' => 'custom_module_one.de.po', | 280 'filename' => 'custom_module_one.de.po', |
279 'version' => '', | 281 'version' => '', |
280 ]; | 282 ]; |
283 $connection = Database::getConnection(); | |
281 foreach ($data as $file) { | 284 foreach ($data as $file) { |
282 $file = array_merge($default, $file); | 285 $file = array_merge($default, $file); |
283 db_insert('locale_file')->fields($file)->execute(); | 286 $connection->insert('locale_file')->fields($file)->execute(); |
284 } | 287 } |
285 } | 288 } |
286 | 289 |
287 /** | 290 /** |
288 * Checks the translation of a string. | 291 * Checks the translation of a string. |