comparison core/lib/Drupal/Core/Theme/ActiveTheme.php @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children 129ea1e6d783
comparison
equal deleted inserted replaced
-1:000000000000 0:4c8ae668cc8c
1 <?php
2
3 namespace Drupal\Core\Theme;
4
5 /**
6 * Defines a theme and its information needed at runtime.
7 *
8 * The theme manager will store the active theme object.
9 *
10 * @see \Drupal\Core\Theme\ThemeManager
11 * @see \Drupal\Core\Theme\ThemeInitialization
12 */
13 class ActiveTheme {
14
15 /**
16 * The machine name of the active theme.
17 *
18 * @var string
19 */
20 protected $name;
21
22 /**
23 * The path to the theme.
24 *
25 * @var string
26 */
27 protected $path;
28
29 /**
30 * The engine of the theme.
31 *
32 * @var string
33 */
34 protected $engine;
35
36 /**
37 * The path to the theme engine for root themes.
38 *
39 * @var string
40 */
41 protected $owner;
42
43 /**
44 * An array of base theme active theme objects keyed by name.
45 *
46 * @var static[]
47 */
48 protected $baseThemes;
49
50 /**
51 * The extension object.
52 *
53 * @var \Drupal\Core\Extension\Extension
54 */
55 protected $extension;
56
57 /**
58 * The stylesheets which are set to be removed by the theme.
59 *
60 * @var array
61 */
62 protected $styleSheetsRemove;
63
64 /**
65 * The libraries provided by the theme.
66 *
67 * @var array
68 */
69 protected $libraries;
70
71 /**
72 * The regions provided by the theme.
73 *
74 * @var array
75 */
76 protected $regions;
77
78 /**
79 * The libraries or library assets overridden by the theme.
80 *
81 * @var array
82 */
83 protected $librariesOverride;
84
85 /**
86 * Constructs an ActiveTheme object.
87 *
88 * @param array $values
89 * The properties of the object, keyed by the names.
90 */
91 public function __construct(array $values) {
92 $values += [
93 'path' => '',
94 'engine' => 'twig',
95 'owner' => 'twig',
96 'stylesheets_remove' => [],
97 'libraries' => [],
98 'extension' => 'html.twig',
99 'base_themes' => [],
100 'regions' => [],
101 'libraries_override' => [],
102 'libraries_extend' => [],
103 ];
104
105 $this->name = $values['name'];
106 $this->path = $values['path'];
107 $this->engine = $values['engine'];
108 $this->owner = $values['owner'];
109 $this->styleSheetsRemove = $values['stylesheets_remove'];
110 $this->libraries = $values['libraries'];
111 $this->extension = $values['extension'];
112 $this->baseThemes = $values['base_themes'];
113 $this->regions = $values['regions'];
114 $this->librariesOverride = $values['libraries_override'];
115 $this->librariesExtend = $values['libraries_extend'];
116 }
117
118 /**
119 * Returns the machine name of the theme.
120 *
121 * @return string
122 */
123 public function getName() {
124 return $this->name;
125 }
126
127 /**
128 * Returns the path to the theme directory.
129 *
130 * @return string
131 */
132 public function getPath() {
133 return $this->path;
134 }
135
136 /**
137 * Returns the theme engine.
138 *
139 * @return string
140 */
141 public function getEngine() {
142 return $this->engine;
143 }
144
145 /**
146 * Returns the path to the theme engine for root themes.
147 *
148 * @see \Drupal\Core\Extension\ThemeHandler::rebuildThemeData
149 *
150 * @return mixed
151 */
152 public function getOwner() {
153 return $this->owner;
154 }
155
156 /**
157 * Returns the extension object.
158 *
159 * @return \Drupal\Core\Extension\Extension
160 */
161 public function getExtension() {
162 return $this->extension;
163 }
164
165 /**
166 * Returns the libraries provided by the theme.
167 *
168 * @return mixed
169 */
170 public function getLibraries() {
171 return $this->libraries;
172 }
173
174 /**
175 * Returns the removed stylesheets by the theme.
176 *
177 * @return mixed
178 *
179 * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
180 *
181 * @see https://www.drupal.org/node/2497313
182 */
183 public function getStyleSheetsRemove() {
184 return $this->styleSheetsRemove;
185 }
186
187 /**
188 * Returns an array of base theme active theme objects keyed by name.
189 *
190 * The order starts with the base theme of $this and ends with the root of
191 * the dependency chain.
192 *
193 * @return static[]
194 */
195 public function getBaseThemes() {
196 return $this->baseThemes;
197 }
198
199 /**
200 * The regions used by the theme.
201 *
202 * @return string[]
203 * The list of region machine names supported by the theme.
204 *
205 * @see system_region_list()
206 */
207 public function getRegions() {
208 return array_keys($this->regions);
209 }
210
211 /**
212 * Returns the libraries or library assets overridden by the active theme.
213 *
214 * @return array
215 * The list of libraries overrides.
216 */
217 public function getLibrariesOverride() {
218 return $this->librariesOverride;
219 }
220
221 /**
222 * Returns the libraries extended by the active theme.
223 *
224 * @return array
225 * The list of libraries-extend definitions.
226 */
227 public function getLibrariesExtend() {
228 return $this->librariesExtend;
229 }
230
231 }