From 234241cfc44b6fe772813d30aad3e9b32d327dcd Mon Sep 17 00:00:00 2001 From: Lukas Kahwe Smith Date: Fri, 13 Sep 2019 20:05:13 +0200 Subject: [PATCH] Laravel 6 compat --- src/Service/SourceEditSync.php | 3 ++- src/SourceSaver.php | 5 +++-- src/TranslationExtractor.php | 3 ++- src/TranslationSaver.php | 6 ++++-- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/Service/SourceEditSync.php b/src/Service/SourceEditSync.php index 963f306..b32fad3 100644 --- a/src/Service/SourceEditSync.php +++ b/src/Service/SourceEditSync.php @@ -2,6 +2,7 @@ namespace Tio\Laravel\Service; +use Illuminate\Support\Str; use Tio\Laravel\SourceSaver; use Carbon\Carbon; use GuzzleHttp\Client; @@ -137,7 +138,7 @@ private function timestampFromMetadataContent($metadataContent) private function throwErrorIfConflictInMetadata($metadataContent) { - if (str_contains($metadataContent, ['>>>>', '<<<<'])) { + if (Str::contains($metadataContent, ['>>>>', '<<<<'])) { $metadataFilePath = $this->metadataFilePath(); throw new SourceEditSyncException($metadataFilePath . " file is corrupted and seems to have unresolved versioning conflicts. Please resolve them and try again."); } diff --git a/src/SourceSaver.php b/src/SourceSaver.php index ebda7c0..1f73071 100644 --- a/src/SourceSaver.php +++ b/src/SourceSaver.php @@ -2,6 +2,7 @@ namespace Tio\Laravel; +use Illuminate\Support\Str; use Tio\Laravel\PrettyVarExport; use Illuminate\Contracts\Foundation\Application; use Illuminate\Filesystem\Filesystem; @@ -40,7 +41,7 @@ public function call($sourceEdit, $sourceLocale) // Adapt $group and $dir if the key contains subfolders: // https://laravel.io/forum/02-23-2015-localization-load-files-from-subdirectories-at-resourceslanglocale) - if (str_contains($key, '/')) { + if (Str::contains($key, '/')) { $subFolders = explode('/', $key); array_pop($subFolders); $dir = join(DIRECTORY_SEPARATOR, array_merge([$dir], $subFolders)); @@ -89,7 +90,7 @@ private function group($key) { $foldersAndGroup = explode('.', $key)[0]; - if (str_contains($foldersAndGroup, '/')) { + if (Str::contains($foldersAndGroup, '/')) { $parts = explode('/', $foldersAndGroup); return array_pop($parts); } diff --git a/src/TranslationExtractor.php b/src/TranslationExtractor.php index 86f45f7..c4da705 100644 --- a/src/TranslationExtractor.php +++ b/src/TranslationExtractor.php @@ -4,6 +4,7 @@ use Illuminate\Contracts\Foundation\Application; use Illuminate\Filesystem\Filesystem; +use Illuminate\Support\Arr; use Illuminate\Translation\Translator; use SplFileInfo; use Symfony\Component\Finder\Finder; @@ -53,7 +54,7 @@ public function call($locale) $group = $file->getBasename('.' . $file->getExtension()); $relativePath = $file->getRelativePath(); - $data = array_dot([ + $data = Arr::dot([ $group => $this->translator->getLoader()->load($locale, $relativePath . DIRECTORY_SEPARATOR . $group) ]); diff --git a/src/TranslationSaver.php b/src/TranslationSaver.php index 1dbd445..8ff12eb 100644 --- a/src/TranslationSaver.php +++ b/src/TranslationSaver.php @@ -3,6 +3,8 @@ namespace Tio\Laravel; use Illuminate\Contracts\Foundation\Application; +use Illuminate\Support\Arr; +use Illuminate\Support\Str; use Tio\Laravel\PrettyVarExport; use Illuminate\Filesystem\Filesystem; use Illuminate\Translation\Translator; @@ -43,7 +45,7 @@ public function call($locale, $translationsDotted) foreach ($translationsDotted as $key => $value) { if ($value !== '' && ! is_null($value)) { - array_set($translationsWithGroups, $key, $value); + Arr::set($translationsWithGroups, $key, $value); } } @@ -59,7 +61,7 @@ private function save($locale, $group, $translations) // Adapt $group and $dir if key contains subfolders: // https://laravel.io/forum/02-23-2015-localization-load-files-from-subdirectories-at-resourceslanglocale) - if (str_contains($group, '/')) { + if (Str::contains($group, '/')) { $subFolders = explode('/', $group); $group = array_pop($subFolders); $dir = join(DIRECTORY_SEPARATOR, array_merge([$dir], $subFolders));