From 4ea499213d2ce1c9b043e87ce1372da4ac14853b Mon Sep 17 00:00:00 2001 From: Kasper Franz Date: Fri, 4 Mar 2016 11:50:59 +0100 Subject: [PATCH 1/2] If the realpath is empty, something is wrong and we should warn the user about it --- src/Xinax/LaravelGettext/FileSystem.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Xinax/LaravelGettext/FileSystem.php b/src/Xinax/LaravelGettext/FileSystem.php index 17254ea..1bd6fd3 100644 --- a/src/Xinax/LaravelGettext/FileSystem.php +++ b/src/Xinax/LaravelGettext/FileSystem.php @@ -93,6 +93,13 @@ public function compileViews(array $viewPaths, $domain) foreach ($viewPaths as $path) { $path = $this->basePath . DIRECTORY_SEPARATOR . $path; + if (empty(realpath($path))) { + throw new Exceptions\DirectoryNotFoundException(sprintf( + 'The source-path: %s, is not found, please check that it exists, and update your config with the right path.', + $path + )); + } + $fs = new \Illuminate\Filesystem\Filesystem($path); $files = $fs->allFiles(realpath($path)); From 707e80dd0578bc0fcae3b664486caf19f880115c Mon Sep 17 00:00:00 2001 From: Kasper Franz Date: Fri, 4 Mar 2016 12:15:47 +0100 Subject: [PATCH 2/2] Check if the file doesn't exists before creating it. --- src/Xinax/LaravelGettext/FileSystem.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/Xinax/LaravelGettext/FileSystem.php b/src/Xinax/LaravelGettext/FileSystem.php index 1bd6fd3..343075a 100644 --- a/src/Xinax/LaravelGettext/FileSystem.php +++ b/src/Xinax/LaravelGettext/FileSystem.php @@ -238,19 +238,26 @@ public function addLocale($localePath, $locale) "LC_MESSAGES" ); - $this->createDirectory($localePath); + if (!file_exists($localePath)) { + $this->createDirectory($localePath); + } if ( $this->configuration->getCustomLocale() ) { $data[1] = 'C'; $gettextPath = implode($data, DIRECTORY_SEPARATOR); - $this->createDirectory($gettextPath); + if (!file_exists($gettextPath)) { + $this->createDirectory($gettextPath); + } $data[2] = 'LC_MESSAGES'; } $gettextPath = implode($data, DIRECTORY_SEPARATOR); - $this->createDirectory($gettextPath); + if (!file_exists($gettextPath)) { + $this->createDirectory($gettextPath); + } + // File generation for each domain foreach ($this->configuration->getAllDomains() as $domain) { @@ -434,8 +441,9 @@ public function checkDirectoryStructure($checkLocales = false) public function generateLocales() { // Application base path - $this->createDirectory($this->getDomainPath()); - + if (!file_exists($this->getDomainPath())) { + $this->createDirectory($this->getDomainPath()); + } $localePaths = []; // Locale directories