Skip to content
This repository was archived by the owner on Feb 10, 2021. It is now read-only.

Commit 094e4f9

Browse files
committed
fixed folder bug
1 parent cdf77d4 commit 094e4f9

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/LanguageSwitcher/Command/RenderLanguageSwitcher.php

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Illuminate\Foundation\Bus\DispatchesJobs;
77
use Illuminate\Http\Request;
88
use Illuminate\Support\Facades\File;
9+
use Illuminate\Filesystem\Filesystem;
910

1011
class RenderLanguageSwitcher
1112
{
@@ -50,22 +51,25 @@ public function handle(
5051
$prefered_url = url()->locale($current_path,$prefered_locale); // Get the current url with the prefered locale
5152
$toggle_title = $this->toggle_title ? $this->toggle_title : $current_locale . " <span class='caret'></span>"; // If the user has passed a button title set it, else default to the currently enabled locale.
5253
$custom_title = $this->toggle_title != false; // Check if the user has set a custom title. Used in building the ul of locales
53-
$composer_folder = '../core/wirelab/language_switcher-plugin/resources/views'; // The location of the views if the user installed the plugin using composer
54-
$manual_folder = File::directories('../addons')[0] . '/wirelab/language_switcher-plugin/resources/views'; // The location of the views if the user installed the plugin manually
54+
$filesystem = new Filesystem;
55+
$composer_folder = base_path() . '/core/wirelab/language_switcher-plugin/resources/views'; // The location of the views if the user installed the plugin using composer
56+
$manual_folder = base_path() . '/addons/' . env('APPLICATION_REFERENCE') . '/wirelab/language_switcher-plugin/resources/views'; // The location of the views if the user installed the plugin manually
57+
$published_folder = base_path() . '/resources' . env('APPLICATION_REFERENCE') . 'addons/wirelab/language_switcher-plugin/views'; // The locations of the views if the user published the views
5558

5659
// Try to find the views folder
57-
if (file_exists($manual_folder)) {
60+
if ($filesystem->exists($published_folder)) {
61+
$views_dir = published_folder;
62+
} elseif ($filesystem->exists($manual_folder)) {
5863
$views_dir = $manual_folder;
59-
} elseif(file_exists($composer_folder )) {
64+
} elseif($filesystem->exists($composer_folder )) {
6065
$views_dir = $composer_folder;
6166
} else {
6267
// If we can't find it throw a new exception
63-
throw new Exception("Couldn't find view folder.");
68+
throw new Exception("[language_switcher-plugin] Couldn't find view folder.");
6469
}
65-
66-
foreach (File::allFiles($views_dir) as $file){
67-
// Use the names of the views as types
68-
$types[] = $file->getBaseName('.' . $file->getExtension());
70+
foreach ($filesystem->allFiles($views_dir) as $file){
71+
// Use the names of the views as networks
72+
types[] = $file->getBaseName('.' . $file->getExtension());
6973
}
7074

7175
if (!in_array($type, $types)) {

0 commit comments

Comments
 (0)