1 | <?php |
||
5 | class Themes |
||
6 | { |
||
7 | protected $theme = null; |
||
8 | |||
9 | /** |
||
10 | * Get the name of the theme for this context. |
||
11 | * Make its path available for view selection |
||
12 | * and override config settings where needed. |
||
13 | * |
||
14 | * @param \Illuminate\Http\Request $request |
||
15 | * @return void |
||
16 | */ |
||
17 | 26 | public function setTheme($request) |
|
18 | { |
||
19 | 26 | $this->findMatch($request); |
|
20 | 24 | $this->addThemeViewPath(); |
|
21 | 24 | $this->applyThemeConfig(); |
|
22 | 24 | } |
|
23 | |||
24 | /** |
||
25 | * Getter for the theme that is chosen. |
||
26 | * |
||
27 | * @return string theme |
||
28 | */ |
||
29 | 22 | public function getTheme() |
|
33 | |||
34 | /** |
||
35 | * Iterate over the match criteria until a successful match is achieved. |
||
36 | * |
||
37 | * @return void |
||
38 | */ |
||
39 | 26 | protected function findMatch($request) |
|
48 | |||
49 | /** |
||
50 | * If there's no match critera or all rules are matched, set the theme and exit. |
||
51 | * |
||
52 | * @return boolean |
||
53 | */ |
||
54 | 26 | protected function testMatch($request, $match) |
|
70 | |||
71 | /** |
||
72 | * Remove whtespace from rules and separate the rules in a match group. |
||
73 | * |
||
74 | * @return array rules |
||
75 | */ |
||
76 | 21 | protected function explodeRules($rules) |
|
81 | |||
82 | /** |
||
83 | * Separate rule name from parameters and pass to matcher class to evaluate. |
||
84 | * |
||
85 | * @return boolean |
||
86 | */ |
||
87 | 21 | protected function handleRule($request, $rule) |
|
95 | |||
96 | /** |
||
97 | * Add path for current theme's views to the list that Laravel searches. |
||
98 | * |
||
99 | * @return void |
||
100 | */ |
||
101 | 24 | protected function addThemeViewPath() |
|
107 | |||
108 | /** |
||
109 | * Override configs with theme-specific settings. |
||
110 | * |
||
111 | * @return void |
||
112 | */ |
||
113 | 24 | protected function applyThemeConfig() |
|
124 | } |
||
125 |