-
Notifications
You must be signed in to change notification settings - Fork 2
/
examples.php
91 lines (63 loc) · 2.36 KB
/
examples.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
require_once __DIR__ . '/vendor/autoload.php';
$basePath = null;
$requiredFields = ['display_name', 'version', 'license',];
/*
* Laravel
if (function_exists('app') && function_exists('base_path') && class_exists('ThemeManager')) {
$allThemes = \ThemeMangaer::all();
$themeExists = ThemeMangaer::themeExists('theme-name');
if ($themeExists) {
$theme = \ThemeMangaer::getTheme('theme-name');
}
else {
$theme = \ThemeManager::first();
}
$themeName = $theme->getName();
$themeMeta = $theme->getInfo();
\ThemeMangaer::addThemeLocation(base_path('/path/to/alternative/themes-folder'));
}
*/
/**
* Via new Class
*/
//Bootstrapping theme php files if autoload.php file is present
(new \ThemeManager\Starter)->bootstrapAutoload();
//OR via helper
theme_manager_starter()->bootstrapAutoload();
//Via new
$themeManager = new \ThemeManager\ThemeManager((new \ThemeManager\Starter)->start());
//Optionally pass in initial base path
$themeManager = new \ThemeManager\ThemeManager((new \ThemeManager\Starter)->start(__DIR__ . '/path/to/themes/'));
//Optional Required Field(s)
$themeManager = new \ThemeManager\ThemeManager((new \ThemeManager\Starter)->start($basePath, $requiredFields));
//Via Theme Manager Starter Helper
$themeManager = new \ThemeManager\ThemeManager(theme_manager_starter()->start());
// Exception On Invalid
$themeManager = new \ThemeManager\ThemeManager(theme_manager_starter()->start($basePath, $requiredFields, true));
/**
* Via Helper
*/
$themeManager = theme_manager();
//Optionally pass in initial base path
$themeManager = theme_manager(__DIR__ . '/path/to/themes/');
//Optional Required Field(s)
$themeManager = theme_manager($basePath, $requiredFields);
// Exception On Invalid
$themeManager = theme_manager($basePath, $requiredFields, true);
//ThemeCollection
$allThemes = $themeManager->all();
//Returns bool
$myThemeExists = $themeManager->themeExists('theme-name') ? 'yes' : 'nope';
//Theme Obj or null
$myTheme = $themeManager->getTheme('theme-name');
//Array
$myThemeInfo = $myTheme->getInfo();
//Array of strings
$themeNames = $themeManager->getAllThemeNames();
//First Theme Obj
$firstTheme = $allThemes->first();
//Last Theme Obj
$lastTheme = $allThemes->last();
//Add another location of themes to the ThemeManager
$themeManager->addThemeLocation(__DIR__ . '/path/to/alternative/themes-folder');