-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathViewManager.php
52 lines (41 loc) · 1.24 KB
/
ViewManager.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
namespace Aerni\LivewireForms;
class ViewManager
{
public function viewPath(string $view): string
{
return config('livewire-forms.view_path', 'livewire/forms')."/{$view}";
}
public function themeViewPath(string $theme, string $view): string
{
$themeView = $this->viewPath("{$theme}/{$view}");
$defaultThemeView = $this->viewPath("{$this->defaultTheme()}/{$view}");
return view()->exists($themeView) ? $themeView : $defaultThemeView;
}
public function themeViewExists(string $theme, string $view): bool
{
return view()->exists($this->themeViewPath($theme, $view));
}
public function viewExists(?string $view): bool
{
if (empty($view)) {
return false;
}
return view()->exists($this->viewPath($view));
}
public function themeExists(?string $theme): bool
{
if (empty($theme)) {
return false;
}
return is_dir(resource_path("views/{$this->viewPath($theme)}"));
}
public function defaultView(): string
{
return config('livewire-forms.view', 'default');
}
public function defaultTheme(): string
{
return config('livewire-forms.theme', 'default');
}
}