/
helpers.php
59 lines (52 loc) · 1.49 KB
/
helpers.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
53
54
55
56
57
58
59
<?php
use Illuminate\Support\Facades\Config;
use ThemeManager\Starter;
use ThemeManager\ThemeManager;
if (! function_exists('themes_base_path')) {
/**
* @return string|bool
*/
function themes_base_path()
{
$base = __DIR__ . '/../../../';
$vendor = realpath($base . 'vendor');
$themes = realpath($base . 'themes');
if (is_dir($vendor)) {
return $themes;
}
if (is_dir($themes)) {
return $themes;
}
if (getenv('APP_ENV') === 'testing') {
return realpath(__DIR__ . '/tests/themes');
}
return false;
}
}
if (! function_exists('theme_manager_starter')) {
/**
* @return \ThemeManager\Starter
*/
function theme_manager_starter()
{
return new Starter;
}
}
if (! function_exists('theme_manager')) {
/**
* @param null $basePath
* @param array $requiredFields
* @param bool $exceptionOnInvalid
*
* @return \ThemeManager\ThemeManager
*/
function theme_manager($basePath = null, array $requiredFields = [], $exceptionOnInvalid = false)
{
if (function_exists('app') && class_exists('Illuminate\Container\Container') &&
Config::get('app.aliases.ThemeManager') == 'ThemeManager\Facade\ThemeManager'
) {
return \ThemeManager::returnThis();
}
return new ThemeManager(theme_manager_starter()->start($basePath, $requiredFields, $exceptionOnInvalid));
}
}