comparison core/lib/Drupal/Core/Extension/ThemeHandlerInterface.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\Extension;
4
5 /**
6 * Manages the list of available themes.
7 */
8 interface ThemeHandlerInterface {
9
10 /**
11 * Installs a given list of themes.
12 *
13 * @param array $theme_list
14 * An array of theme names.
15 * @param bool $install_dependencies
16 * (optional) If TRUE, dependencies will automatically be installed in the
17 * correct order. This incurs a significant performance cost, so use FALSE
18 * if you know $theme_list is already complete and in the correct order.
19 *
20 * @return bool
21 * Whether any of the given themes have been installed.
22 *
23 * @throws \Drupal\Core\Extension\ExtensionNameLengthException
24 * Thrown when the theme name is to long.
25 *
26 * @deprecated in Drupal 8.0.x-dev and will be removed before Drupal 9.0.0.
27 * Use the theme_installer service instead.
28 *
29 * @see \Drupal\Core\Extension\ThemeInstallerInterface::install
30 */
31 public function install(array $theme_list, $install_dependencies = TRUE);
32
33 /**
34 * Uninstalls a given list of themes.
35 *
36 * Uninstalling a theme removes all related configuration (like blocks) and
37 * invokes the 'themes_uninstalled' hook.
38 *
39 * @param array $theme_list
40 * The themes to uninstall.
41 *
42 * @throws \InvalidArgumentException
43 * Thrown when you uninstall an not installed theme.
44 *
45 * @see hook_themes_uninstalled()
46 *
47 * @deprecated in Drupal 8.0.x-dev and will be removed before Drupal 9.0.0.
48 * Use the theme_installer service instead.
49 *
50 * @see \Drupal\Core\Extension\ThemeInstallerInterface::uninstall
51 */
52 public function uninstall(array $theme_list);
53
54 /**
55 * Returns a list of currently installed themes.
56 *
57 * @return \Drupal\Core\Extension\Extension[]
58 * An associative array of the currently installed themes. The keys are the
59 * themes' machine names and the values are objects having the following
60 * properties:
61 * - filename: The filepath and name of the .info.yml file.
62 * - name: The machine name of the theme.
63 * - status: 1 for installed, 0 for uninstalled themes.
64 * - info: The contents of the .info.yml file.
65 * - stylesheets: A two dimensional array, using the first key for the
66 * media attribute (e.g. 'all'), the second for the name of the file
67 * (e.g. style.css). The value is a complete filepath (e.g.
68 * themes/bartik/style.css). Not set if no stylesheets are defined in the
69 * .info.yml file.
70 * - scripts: An associative array of JavaScripts, using the filename as key
71 * and the complete filepath as value. Not set if no scripts are defined
72 * in the .info.yml file.
73 * - prefix: The base theme engine prefix.
74 * - engine: The machine name of the theme engine.
75 * - base_theme: If this is a sub-theme, the machine name of the base theme
76 * defined in the .info.yml file. Otherwise, the element is not set.
77 * - base_themes: If this is a sub-theme, an associative array of the
78 * base-theme ancestors of this theme, starting with this theme's base
79 * theme, then the base theme's own base theme, etc. Each entry has an
80 * array key equal to the theme's machine name, and a value equal to the
81 * human-readable theme name; if a theme with matching machine name does
82 * not exist in the system, the value will instead be NULL (and since the
83 * system would not know whether that theme itself has a base theme, that
84 * will end the array of base themes). This is not set if the theme is not
85 * a sub-theme.
86 * - sub_themes: An associative array of themes on the system that are
87 * either direct sub-themes (that is, they declare this theme to be
88 * their base theme), direct sub-themes of sub-themes, etc. The keys are
89 * the themes' machine names, and the values are the themes'
90 * human-readable names. This element is not set if there are no themes on
91 * the system that declare this theme as their base theme.
92 */
93 public function listInfo();
94
95
96 /**
97 * Adds a theme extension to the internal listing.
98 *
99 * @param \Drupal\Core\Extension\Extension $theme
100 * The theme extension.
101 */
102 public function addTheme(Extension $theme);
103
104 /**
105 * Refreshes the theme info data of currently installed themes.
106 *
107 * Modules can alter theme info, so this is typically called after a module
108 * has been installed or uninstalled.
109 */
110 public function refreshInfo();
111
112 /**
113 * Resets the internal state of the theme handler.
114 */
115 public function reset();
116
117 /**
118 * Scans and collects theme extension data and their engines.
119 *
120 * @return \Drupal\Core\Extension\Extension[]
121 * An associative array of theme extensions.
122 */
123 public function rebuildThemeData();
124
125 /**
126 * Finds all the base themes for the specified theme.
127 *
128 * Themes can inherit templates and function implementations from earlier
129 * themes.
130 *
131 * @param \Drupal\Core\Extension\Extension[] $themes
132 * An array of available themes.
133 * @param string $theme
134 * The name of the theme whose base we are looking for.
135 *
136 * @return array
137 * Returns an array of all of the theme's ancestors; the first element's
138 * value will be NULL if an error occurred.
139 */
140 public function getBaseThemes(array $themes, $theme);
141
142 /**
143 * Gets the human readable name of a given theme.
144 *
145 * @param string $theme
146 * The machine name of the theme which title should be shown.
147 *
148 * @return string
149 * Returns the human readable name of the theme.
150 */
151 public function getName($theme);
152
153 /**
154 * Returns the default theme.
155 *
156 * @return string
157 * The default theme.
158 */
159 public function getDefault();
160
161 /**
162 * Sets a new default theme.
163 *
164 * @param string $theme
165 * The new default theme.
166 *
167 * @return $this
168 *
169 * @deprecated in Drupal 8.2.x-dev and will be removed before Drupal 9.0.0.
170 * Use
171 * @code
172 * \Drupal::configFactory()
173 * ->getEditable('system.theme')
174 * ->set('default', $theme)
175 * ->save();
176 * @endcode
177 */
178 public function setDefault($theme);
179
180 /**
181 * Returns an array of directories for all installed themes.
182 *
183 * Useful for tasks such as finding a file that exists in all theme
184 * directories.
185 *
186 * @return array
187 */
188 public function getThemeDirectories();
189
190 /**
191 * Determines whether a given theme is installed.
192 *
193 * @param string $theme
194 * The name of the theme (without the .theme extension).
195 *
196 * @return bool
197 * TRUE if the theme is installed.
198 */
199 public function themeExists($theme);
200
201 /**
202 * Returns a theme extension object from the currently active theme list.
203 *
204 * @param string $name
205 * The name of the theme to return.
206 *
207 * @return \Drupal\Core\Extension\Extension
208 * An extension object.
209 *
210 * @throws \InvalidArgumentException
211 * Thrown when the requested theme does not exist.
212 */
213 public function getTheme($name);
214
215 /**
216 * Determines if a theme should be shown in the user interface.
217 *
218 * To be shown in the UI the theme has to be installed. If the theme is hidden
219 * it will not be shown unless it is the default or admin theme.
220 *
221 * @param string $name
222 * The name of the theme to check.
223 *
224 * @return bool
225 * TRUE if the theme should be shown in the UI, FALSE if not.
226 */
227 public function hasUi($name);
228
229 }