forked from monkblog/theme-manager
/
helpers.php
45 lines (41 loc) · 1.21 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
<?php
if( !function_exists( 'themes_base_path' ) ) {
/**
* @return string|boolean
*/
function themes_base_path()
{
if( is_dir( realpath( __DIR__ . '/../../../vendor' ) ) ) {
return realpath( __DIR__ . '/../../../themes' );
}
if( is_dir( realpath( __DIR__ . '/../../../themes' ) ) ) {
return realpath( __DIR__ . '/../../../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 \ThemeManager\Starter;
}
}
if( !function_exists( 'theme_manager' ) ) {
/**
* @param null $basePath
*
* @param array $requiredFields
* @param boolean $exceptionOnInvalid
*
* @return \ThemeManager\ThemeManager
*/
function theme_manager( $basePath = null, Array $requiredFields = [], $exceptionOnInvalid = false )
{
return new \ThemeManager\ThemeManager( theme_manager_starter()->start( $basePath, $requiredFields, $exceptionOnInvalid ) );
}
}