Version 1
[yaffs-website] / web / themes / contrib / bootstrap / deprecated.php
1 <?php
2 /**
3  * @file
4  * This contains deprecated functions that will be removed in a future release.
5  */
6
7 use Drupal\bootstrap\Bootstrap;
8 use Drupal\bootstrap\Plugin\ProviderManager;
9 use Drupal\bootstrap\Utility\Element;
10 use Drupal\bootstrap\Utility\Unicode;
11 use Drupal\Component\Utility\NestedArray;
12
13 /**
14  * The base file system path for CDN providers.
15  *
16  * @deprecated Will be removed in a future release.
17  *
18  * @code
19  *   // Before.
20  *   echo BOOTSTRAP_CDN_PROVIDER_PATH;
21  *
22  *   // After.
23  *   use Drupal\bootstrap\Plugin\ProviderManager;
24  *   echo ProviderManager::FILE_PATH;
25  * @endcode
26  *
27  * @see \Drupal\bootstrap\Plugin\ProviderManager::FILE_PATH
28  */
29 define('BOOTSTRAP_CDN_PROVIDER_PATH', ProviderManager::FILE_PATH);
30
31 /**
32  * The current supported Bootstrap framework major version number.
33  *
34  * @deprecated Will be removed in a future release.
35  *
36  * @code
37  *   // Before.
38  *   echo BOOTSTRAP_VERSION_MAJOR;
39  *
40  *   // After.
41  *   use Drupal\bootstrap\Bootstrap;
42  *   echo substr(Bootstrap::FRAMEWORK_VERSION, 0, 1);
43  * @endcode
44  *
45  * @see \Drupal\bootstrap\Bootstrap::FRAMEWORK_VERSION
46  */
47 define('BOOTSTRAP_VERSION_MAJOR', substr(Bootstrap::FRAMEWORK_VERSION, 0, 1));
48
49 /**
50  * The current supported Bootstrap framework minor version number.
51  *
52  * @deprecated Will be removed in a future release.
53  *
54  * @code
55  *   // Before.
56  *   echo BOOTSTRAP_VERSION_MINOR;
57  *
58  *   // After.
59  *   use Drupal\bootstrap\Bootstrap;
60  *   echo substr(Bootstrap::FRAMEWORK_VERSION, 2, 1);
61  * @endcode
62  *
63  * @see \Drupal\bootstrap\Bootstrap::FRAMEWORK_VERSION
64  */
65 define('BOOTSTRAP_VERSION_MINOR', substr(Bootstrap::FRAMEWORK_VERSION, 2, 1));
66
67 /**
68  * The current supported Bootstrap framework patch version number.
69  *
70  * @deprecated Will be removed in a future release.
71  *
72  * @code
73  *   // Before.
74  *   echo BOOTSTRAP_VERSION_PATCH;
75  *
76  *   // After.
77  *   use Drupal\bootstrap\Bootstrap;
78  *   echo substr(Bootstrap::FRAMEWORK_VERSION, 4, 1);
79  * @endcode
80  *
81  * @see \Drupal\bootstrap\Bootstrap::FRAMEWORK_VERSION
82  */
83 define('BOOTSTRAP_VERSION_PATCH', substr(Bootstrap::FRAMEWORK_VERSION, 4, 1));
84
85 /**
86  * The current supported Bootstrap framework version.
87  *
88  * @deprecated Will be removed in a future release.
89  *
90  * @code
91  *   // Before.
92  *   echo BOOTSTRAP_VERSION;
93  *
94  *   // After.
95  *   use Drupal\bootstrap\Bootstrap;
96  *   echo Bootstrap::FRAMEWORK_VERSION;
97  * @endcode
98  *
99  * @see \Drupal\bootstrap\Bootstrap::FRAMEWORK_VERSION
100  */
101 define('BOOTSTRAP_VERSION', Bootstrap::FRAMEWORK_VERSION);
102
103 /**
104  * Adds a class to an element's render array.
105  *
106  * @param string|array $class
107  *   An individual class or an array of classes to add.
108  * @param array $element
109  *   The individual renderable array element. It is possible to also pass the
110  *   $variables parameter in [pre]process functions and it will logically
111  *   determine the correct path to that particular theme hook's classes array.
112  *   Passed by reference.
113  * @param string $property
114  *   Determines which attributes array to retrieve. By default, this is the
115  *   element's normal "attributes", but it could also be one of the following:
116  *   - "content_attributes"
117  *   - "input_group_attributes"
118  *   - "title_attributes"
119  *   - "wrapper_attributes".
120  *
121  * @deprecated Will be removed in a future release.
122  *
123  * @code
124  *   // Before.
125  *   _bootstrap_add_class('my-class', $element);
126  *
127  *   // After.
128  *   use Drupal\bootstrap\Utility\Element;
129  *   Element::create($element)->addClass('my-class');
130  * @endcode
131  *
132  * @see \Drupal\bootstrap\Utility\Element::addClass()
133  */
134 function _bootstrap_add_class($class, array &$element, $property = 'attributes') {
135   Bootstrap::deprecated();
136   Element::create($element)->addClass($class, $property);
137 }
138
139 /**
140  * Adds a specific Bootstrap class to color a button based on its text value.
141  *
142  * @param array $element
143  *   The form element, passed by reference.
144  *
145  * @deprecated Will be removed in a future release.
146  *
147  * @code
148  *   // Before.
149  *   _bootstrap_colorize_button($element);
150  *
151  *   // After.
152  *   use Drupal\bootstrap\Utility\Element;
153  *   Element::create($element)->colorize();
154  * @endcode
155  *
156  * @see \Drupal\bootstrap\Utility\Element::colorize()
157  * */
158 function _bootstrap_colorize_button(array &$element) {
159   Bootstrap::deprecated();
160   Element::create($element)->colorize();
161 }
162
163 /**
164  * Matches a Bootstrap class based on a string value.
165  *
166  * @param string $string
167  *   The string to match classes against.
168  * @param string $default
169  *   The default class to return if no match is found.
170  *
171  * @return string
172  *   The Bootstrap class matched against the value of $haystack or $default if
173  *   no match could be made.
174  *
175  * @deprecated Will be removed in a future release.
176  *
177  * @code
178  *   // Before.
179  *   $class = _bootstrap_colorize_text($string, $default);
180  *
181  *   // After.
182  *   use Drupal\bootstrap\Bootstrap;
183  *   $class = Bootstrap::cssClassFromString($string, $default);
184  * @endcode
185  *
186  * @see \Drupal\bootstrap\Bootstrap::cssClassFromString()
187  */
188 function _bootstrap_colorize_text($string, $default = '') {
189   Bootstrap::deprecated();
190   return Bootstrap::cssClassFromString($string, $default);
191 }
192
193 /**
194  * Wrapper for the core file_scan_directory() function.
195  *
196  * Finds all files that match a given mask in a given directory and then caches
197  * the results. A general site cache clear will force new scans to be initiated
198  * for already cached directories.
199  *
200  * @param string $dir
201  *   The base directory or URI to scan, without trailing slash.
202  * @param string $mask
203  *   The preg_match() regular expression of the files to find.
204  * @param array $options
205  *   Additional options to pass to file_scan_directory().
206  *
207  * @return array
208  *   An associative array (keyed on the chosen key) of objects with 'uri',
209  *   'filename', and 'name' members corresponding to the matching files.
210  *
211  * @deprecated Will be removed in a future release.
212  *
213  * @code
214  *   // Before.
215  *   $files = _bootstrap_file_scan_directory($theme_path . '/js', '/\.js$/');
216  *
217  *   // After.
218  *   use Drupal\bootstrap\Bootstrap;
219  *   $files = Bootstrap::getTheme()->fileScan('/\.js$/', 'js');
220  * @endcode
221  *
222  * @see \Drupal\bootstrap\Theme::fileScan()
223  * @see file_scan_directory()
224  */
225 function _bootstrap_file_scan_directory($dir, $mask, array $options = []) {
226   Bootstrap::deprecated();
227   $theme = Bootstrap::getTheme();
228   $dir = preg_replace('/^' . preg_quote($theme->getPath()) . '\//', '', $dir);
229   return $theme->fileScan($mask, $dir, $options);
230 }
231
232 /**
233  * Retrieves an element's "attributes" array.
234  *
235  * @param array $element
236  *   The individual renderable array element, passed by reference.
237  * @param string $property
238  *   Determines which attributes array to retrieve. By default, this is the
239  *   element's normal "attributes", but it could also be one of the following:
240  *   - "content_attributes"
241  *   - "input_group_attributes"
242  *   - "title_attributes"
243  *   - "wrapper_attributes".
244  *
245  * @return array
246  *   The attributes array.
247  *
248  * @deprecated Will be removed in a future release.
249  *
250  * @code
251  *   // Before.
252  *   $attributes = &_bootstrap_get_attributes($element);
253  *   $attributes['class'][] = 'my-class';
254  *
255  *   // After.
256  *   use Drupal\bootstrap\Utility\Element;
257  *   $attributes = &Element::create($element)->getAttributes();
258  *   $attributes['class'][] = 'my-class';
259  * @endcode
260  *
261  * @see \Drupal\bootstrap\Utility\Element::getAttributes()
262  */
263 function &_bootstrap_get_attributes(array &$element, $property = 'attributes') {
264   Bootstrap::deprecated();
265   return Element::create($element)->getAttributes($property);
266 }
267
268 /**
269  * Returns a list of base themes for active or provided theme.
270  *
271  * @param string $theme_key
272  *   The machine name of the theme to check, if not set the active theme name
273  *   will be used.
274  * @param bool $include_theme_key
275  *   Whether to append the returned list with $theme_key.
276  *
277  * @return array
278  *   An indexed array of base themes.
279  *
280  * @deprecated Will be removed in a future release.
281  *
282  * @code
283  *   // Before (including active theme).
284  *   $base_themes = _bootstrap_get_base_themes(NULL, TRUE);
285  *
286  *   // Before (excluding active theme).
287  *   $base_themes = _bootstrap_get_base_themes('my_subtheme');
288  *
289  *   // After (including active theme).
290  *   use Drupal\bootstrap\Bootstrap;
291  *   $theme = Bootstrap::getTheme();
292  *   $base_themes = array_keys($theme->getAncestry());
293  *
294  *   // After (excluding active theme).
295  *   use Drupal\bootstrap\Bootstrap;
296  *   $my_subtheme = Bootstrap::getTheme('my_subtheme');
297  *   $base_themes = array_keys($my_subtheme->getAncestry());
298  *   array_pop($base_themes);
299  * @endcode
300  *
301  * @see \Drupal\bootstrap\Theme::getAncestry()
302  */
303 function _bootstrap_get_base_themes($theme_key = NULL, $include_theme_key = FALSE) {
304   Bootstrap::deprecated();
305   $themes = array_keys(Bootstrap::getTheme($theme_key)->getAncestry());
306   if (!$include_theme_key) {
307     array_pop($themes);
308   }
309   return $themes;
310 }
311
312 /**
313  * Retrieves an element's "class" attribute array.
314  *
315  * @param array $element
316  *   The individual renderable array element, passed by reference.
317  * @param string $property
318  *   Determines which attributes array to retrieve. By default, this is the
319  *   element's normal "attributes", but it could also be one of the following:
320  *   - "content_attributes"
321  *   - "input_group_attributes"
322  *   - "title_attributes"
323  *   - "wrapper_attributes".
324  *
325  * @return array
326  *   The classes array.
327  *
328  * @deprecated Will be removed in a future release. There is no replacement.
329  *
330  * @code
331  *   // Before.
332  *   $classes = &_bootstrap_get_classes($element);
333  *   $classes[] = 'my-class';
334  *
335  *   // After.
336  *   use Drupal\bootstrap\Utility\Element;
337  *   $classes = &Element::create($element)->getClasses();
338  *   $classes[] = 'my-class';
339  * @endcode
340  *
341  * @see \Drupal\bootstrap\Utility\Element::getClasses()
342  */
343 function &_bootstrap_get_classes(array &$element, $property = 'attributes') {
344   Bootstrap::deprecated();
345   return Element::create($element)->getClasses($property);
346 }
347
348 /**
349  * Returns a list of available Bootstrap Glyphicons.
350  *
351  * @param string $version
352  *   The specific version of glyphicons to return. If not set, the latest
353  *   BOOTSTRAP_VERSION will be used.
354  *
355  * @return array
356  *   An associative array of icons keyed by their classes.
357  *
358  * @deprecated Will be removed in a future release.
359  *
360  * @code
361  *   // Before.
362  *   $glyphicons = _bootstrap_glyphicons($version);
363  *
364  *   // After.
365  *   use Drupal\bootstrap\Bootstrap;
366  *   $glyphicons = Bootstrap::glyphicons($version);
367  * @endcode
368  *
369  * @see \Drupal\bootstrap\Bootstrap::glyphicons()
370  */
371 function _bootstrap_glyphicons($version = NULL) {
372   Bootstrap::deprecated();
373   return Bootstrap::glyphicons($version);
374 }
375
376 /**
377  * Determine whether or not Bootstrap Glyphicons can be used.
378  *
379  * @deprecated Will be removed in a future release.
380  *
381  * @code
382  *   // Before.
383  *   $supported = _bootstrap_glyphicons_supported();
384  *
385  *   // After.
386  *   use Drupal\bootstrap\Bootstrap;
387  *   $theme = Bootstrap::getTheme();
388  *   $supported = $theme->hasGlyphicons();
389  * @endcode
390  *
391  * @see \Drupal\bootstrap\Theme::hasGlyphicons()
392  */
393 function _bootstrap_glyphicons_supported() {
394   Bootstrap::deprecated();
395   return Bootstrap::getTheme()->hasGlyphicons();
396 }
397
398 /**
399  * Returns a specific Bootstrap Glyphicon.
400  *
401  * @param string $name
402  *   The icon name, minus the "glyphicon-" prefix.
403  * @param string $default
404  *   (Optional) The default value to return.
405  *
406  * @return string
407  *   The HTML markup containing the icon defined by $name, $default value if
408  *   icon does not exist or returns empty output for whatever reason.
409  *
410  * @deprecated Will be removed in a future release.
411  *
412  * @code
413  *   // Before.
414  *   $icon = _bootstrap_icon($name, $default);
415  *
416  *   // After.
417  *   use Drupal\bootstrap\Bootstrap;
418  *   use Drupal\bootstrap\Utility\Element;
419  *   $icon = (string) Element::createStandalone(Bootstrap::glyphicon($name, ['#markup' => $default]))->renderPlain();
420  * @endcode
421  *
422  * @see \Drupal\bootstrap\Bootstrap::glyphicon()
423  */
424 function _bootstrap_icon($name, $default = NULL) {
425   Bootstrap::deprecated();
426   return Element::createStandalone(Bootstrap::glyphicon($name, ['#markup' => $default]))->renderPlain();
427 }
428
429 /**
430  * Adds an icon to button element based on its text value.
431  *
432  * @param array $element
433  *   The form element, passed by reference.
434  *
435  * @deprecated Will be removed in a future release.
436  *
437  * @code
438  *   // Before.
439  *   _bootstrap_iconize_button($element);
440  *
441  *   // After.
442  *   use Drupal\bootstrap\Utility\Element;
443  *   Element::create($element)->setIcon();
444  * @endcode
445  *
446  * @see \Drupal\bootstrap\Utility\Element::setIcon()
447  */
448 function _bootstrap_iconize_button(array &$element) {
449   Bootstrap::deprecated();
450   Element::create($element)->setIcon();
451 }
452
453 /**
454  * Matches a Bootstrap Glyphicon based on a string value.
455  *
456  * @param string $string
457  *   The string to match classes against.
458  * @param string $default
459  *   The default icon to return if no match is found.
460  *
461  * @return string
462  *   The Bootstrap icon matched against the value of $haystack or $default if
463  *   no match could be made.
464  *
465  * @deprecated Will be removed in a future release.
466  *
467  * @code
468  *   // Before.
469  *   $icon = _bootstrap_iconize_text($string, $default);
470  *
471  *   // After.
472  *   use Drupal\bootstrap\Bootstrap;
473  *   $icon = Bootstrap::glyphiconFromString($string, ['#markup' => $default]);
474  * @endcode
475  *
476  * @see \Drupal\bootstrap\Bootstrap::glyphiconFromString()
477  */
478 function _bootstrap_iconize_text($string, $default = '') {
479   Bootstrap::deprecated();
480   return Bootstrap::glyphiconFromString($string, ['#markup' => $default]);
481 }
482
483 /**
484  * Determines if an element is a button.
485  *
486  * @param array $element
487  *   A render array element.
488  *
489  * @return bool
490  *   TRUE or FALSE.
491  *
492  * @deprecated Will be removed in a future release.
493  *
494  * @code
495  *   // Before.
496  *   $button = _bootstrap_is_button($element);
497  *
498  *   // After.
499  *   use Drupal\bootstrap\Utility\Element;
500  *   $button = Element::create($element)->isButton();
501  * @endcode
502  *
503  * @see \Drupal\bootstrap\Utility\Element::isButton()
504  */
505 function _bootstrap_is_button(array $element) {
506   Bootstrap::deprecated();
507   return Element::create($element)->isButton();
508 }
509
510 /**
511  * Determines if a string of text is considered "simple".
512  *
513  * @param string $string
514  *   The string of text to check "simple" criteria on.
515  * @param int|FALSE $length
516  *   The length of characters used to determine whether or not $string is
517  *   considered "simple". Set explicitly to FALSE to disable this criteria.
518  * @param array|FALSE $allowed_tags
519  *   An array of allowed tag elements. Set explicitly to FALSE to disable this
520  *   criteria.
521  * @param bool $html
522  *   A variable, passed by reference, that indicates whether or not the
523  *   string contains HTML.
524  *
525  * @return bool
526  *   Returns TRUE if the $string is considered "simple", FALSE otherwise.
527  *
528  * @deprecated Will be removed in a future release.
529  *
530  * @code
531  *   // Before.
532  *   $simple = _bootstrap_is_simple_string($string, $length, $allowed_tags, $html);
533  *
534  *   // After.
535  *   use Drupal\bootstrap\Utility\Unicode;
536  *   $simple = Unicode::isSimple($string, $length, $allowed_tags, $html);
537  * @endcode
538  *
539  * @see \Drupal\bootstrap\Utility\Unicode::isSimple()
540  */
541 function _bootstrap_is_simple_string($string, $length = 250, $allowed_tags = NULL, &$html = FALSE) {
542   Bootstrap::deprecated();
543   return Unicode::isSimple($string, $length, $allowed_tags, $html);
544 }
545
546 /**
547  * Removes a class from an element's attributes array.
548  *
549  * @param string|array $class
550  *   An individual class or an array of classes to remove.
551  * @param array $element
552  *   The individual renderable array element.
553  * @param string $property
554  *   Determines which attributes array to retrieve. By default, this is the
555  *   element's normal "attributes", but it could also be one of the following:
556  *   - "content_attributes"
557  *   - "input_group_attributes"
558  *   - "title_attributes"
559  *   - "wrapper_attributes".
560  *
561  * @deprecated Will be removed in a future release.
562  *
563  * @code
564  *   // Before.
565  *   _bootstrap_remove_class('my-class', $element);
566  *
567  *   // After.
568  *   use Drupal\bootstrap\Utility\Element;
569  *   Element::create($element)->removeClass('my-class');
570  * @endcode
571  *
572  * @see \Drupal\bootstrap\Utility\Element::removeClass()
573  */
574 function _bootstrap_remove_class($class, array &$element, $property = 'attributes') {
575   Bootstrap::deprecated();
576   Element::create($element)->removeClass($class, $property);
577 }
578
579 /**
580  * Retrieves a list of available CDN providers for the Bootstrap framework.
581  *
582  * @param string $provider
583  *   A specific provider data to return.
584  * @param bool $reset
585  *   Toggle determining whether or not to reset the database cache.
586  *
587  * @return array|FALSE
588  *   An associative array of CDN providers, keyed by their machine name if
589  *   $provider is not set. If $provider is set and exists, it's individual
590  *   data array will be returned. If $provider is set and the data does not
591  *   exist then FALSE will be returned.
592  *
593  * @deprecated Will be removed in a future release.
594  *
595  * @code
596  *   // Before.
597  *   $providers = bootstrap_cdn_provider();
598  *   $jsdelivr = bootstrap_cdn_provider('jsdelivr');
599  *
600  *   // After.
601  *   use Drupal\bootstrap\Bootstrap;
602  *   use Drupal\bootstrap\Plugin\ProviderManager;
603  *
604  *   $theme = Bootstrap::getTheme();
605  *
606  *   // Get provider definitions, the "equivalent" for bootstrap_cdn_provider().
607  *   $provider_manager = new ProviderManager($theme);
608  *   $providers = $provider_manager->getDefinitions();
609  *   $jsdelivr = $provider_manager->getDefinition('jsdelivr');
610  *
611  *   // You should, however, use the the fully initialized classes made
612  *   // available through a theme instance.
613  *   $providers = $theme->getProviders();
614  *   $jsdelivr = $theme->getProvider('jsdelivr');
615  * @endcode
616  *
617  * @see \Drupal\bootstrap\Plugin\ProviderManager
618  * @see \Drupal\bootstrap\Theme::getProviders()
619  * @see \Drupal\bootstrap\Theme::getProvider()
620  */
621 function bootstrap_cdn_provider($provider = NULL, $reset = FALSE) {
622   Bootstrap::deprecated();
623   $provider_manager = new ProviderManager(Bootstrap::getTheme());
624   if ($reset) {
625     $provider_manager->clearCachedDefinitions();
626   }
627   if (isset($provider)) {
628     if ($provider_manager->hasDefinition($provider)) {
629       return $provider_manager->getDefinition($provider);
630     }
631     return FALSE;
632   }
633   return $provider_manager->getDefinitions();
634 }
635
636 /**
637  * Converts an element description into a tooltip based on certain criteria.
638  *
639  * @param array $element
640  *   An element render array, passed by reference.
641  * @param array $target
642  *   The target element render array the tooltip is to be attached to, passed
643  *   by reference. If not set, it will default to the $element passed.
644  * @param bool $input_only
645  *   Toggle determining whether or not to only convert input elements.
646  * @param int $length
647  *   The length of characters to determine if description is "simple".
648  *
649  * @deprecated Will be removed in a future release.
650  *
651  * @code
652  *   // Before.
653  *   bootstrap_element_smart_description($element, $target, $input_only, $length);
654  *
655  *   // After.
656  *   use Drupal\bootstrap\Utility\Element;
657  *   Element::create($element)->smartDescription($target, $input_only, $length);
658  * @endcode
659  *
660  * @see \Drupal\bootstrap\Utility\Element::smartDescription()
661  */
662 function bootstrap_element_smart_description(array &$element, array &$target = NULL, $input_only = TRUE, $length = NULL) {
663   Bootstrap::deprecated();
664   Element::create($element)->smartDescription($target, $input_only, $length);
665 }
666
667 /**
668  * Retrieves CDN assets for the active provider, if any.
669  *
670  * @param string|array $type
671  *   The type of asset to retrieve: "css" or "js", defaults to an array
672  *   array containing both if not set.
673  * @param string $provider
674  *   The name of a specific CDN provider to use, defaults to the active provider
675  *   set in the theme settings.
676  * @param string $theme
677  *   The name of a specific theme the settings should be retrieved from,
678  *   defaults to the active theme.
679  *
680  * @return array
681  *   If $type is a string or an array with only one (1) item in it, the assets
682  *   are returned as an indexed array of files. Otherwise, an associative array
683  *   is returned keyed by the type.
684  *
685  * @deprecated Will be removed in a future release.
686  *
687  * @code
688  *   // Before.
689  *   $assets = bootstrap_get_cdn_assets($type, $provider, $theme);
690  *
691  *   // After.
692  *   use Drupal\bootstrap\Bootstrap;
693  *   $theme = Bootstrap::getTheme($theme);
694  *   $assets = [];
695  *   if ($provider = $theme->getProvider($provider)) {
696  *     $assets = $provider->getAssets($type);
697  *   }
698  * @endcode
699  *
700  * @see \Drupal\bootstrap\Plugin\Provider\Custom::getAssets()
701  * @see \Drupal\bootstrap\Plugin\Provider\JsDelivr::getAssets()
702  * @see \Drupal\bootstrap\Plugin\Provider\ProviderBase::getAssets()
703  * @see \Drupal\bootstrap\Plugin\Provider\ProviderInterface::getAssets()
704  * @see \Drupal\bootstrap\Theme::getProvider()
705  * @see \Drupal\bootstrap\Bootstrap::getTheme()
706  */
707 function bootstrap_get_cdn_assets($type = NULL, $provider = NULL, $theme = NULL) {
708   Bootstrap::deprecated();
709   $assets = [];
710   if ($provider = Bootstrap::getTheme($theme)->getProvider($provider)) {
711     $assets = $provider->getAssets($type);
712   }
713   return $assets;
714 }
715
716 /**
717  * Return information from the .info file of a theme (and possible base themes).
718  *
719  * @param string $theme_key
720  *   The machine name of the theme.
721  * @param string $key
722  *   The key name of the item to return from the .info file. This value can
723  *   include "][" to automatically attempt to traverse any arrays.
724  * @param bool $base_themes
725  *   Recursively search base themes, defaults to TRUE.
726  *
727  * @return string|array|false
728  *   A string or array depending on the type of value and if a base theme also
729  *   contains the same $key, FALSE if no $key is found.
730  *
731  * @deprecated Will be removed in a future release. There is no replacement.
732  */
733 function bootstrap_get_theme_info($theme_key = NULL, $key = NULL, $base_themes = TRUE) {
734   Bootstrap::deprecated();
735   // If no $theme_key is given, use the current theme if we can determine it.
736   if (!isset($theme_key)) {
737     $theme_key = !empty($GLOBALS['theme_key']) ? $GLOBALS['theme_key'] : FALSE;
738   }
739   if ($theme_key) {
740     $themes = \Drupal::service('theme_handler')->listInfo();
741     if (!empty($themes[$theme_key])) {
742       $theme = $themes[$theme_key];
743       // If a key name was specified, return just that array.
744       if ($key) {
745         $value = FALSE;
746         // Recursively add base theme values.
747         if ($base_themes && isset($theme->base_themes)) {
748           foreach (array_keys($theme->base_themes) as $base_theme) {
749             $value = bootstrap_get_theme_info($base_theme, $key);
750           }
751         }
752         if (!empty($themes[$theme_key])) {
753           $info = $themes[$theme_key]->info;
754           // Allow array traversal.
755           $keys = explode('][', $key);
756           foreach ($keys as $parent) {
757             if (isset($info[$parent])) {
758               $info = $info[$parent];
759             }
760             else {
761               $info = FALSE;
762             }
763           }
764           if (is_array($value)) {
765             if (!empty($info)) {
766               if (!is_array($info)) {
767                 $info = [$info];
768               }
769               $value = NestedArray::mergeDeep($value, $info);
770             }
771           }
772           else {
773             if (!empty($info)) {
774               if (empty($value)) {
775                 $value = $info;
776               }
777               else {
778                 if (!is_array($value)) {
779                   $value = [$value];
780                 }
781                 if (!is_array($info)) {
782                   $info = [$info];
783                 }
784                 $value = NestedArray::mergeDeep($value, $info);
785               }
786             }
787           }
788         }
789         return $value;
790       }
791       // If no info $key was specified, just return the entire info array.
792       return $theme->info;
793     }
794   }
795   return FALSE;
796 }
797
798 /**
799  * Includes a file from a theme.
800  *
801  * @param string $theme
802  *   Name of the theme to use for base path.
803  * @param string $path
804  *   Path relative to $theme.
805  *
806  * @deprecated Will be removed in a future release.
807  *
808  * @code
809  *   // Before.
810  *   bootstrap_include('my_subtheme', 'includes/file.inc');
811  *   bootstrap_include('my_subtheme', 'some/other/path/file.inc');
812  *
813  *   // After.
814  *   use Drupal\bootstrap\Bootstrap;
815  *   $my_subtheme = Bootstrap::getTheme('my_subtheme');
816  *   $my_subtheme->includeOnce('file.inc');
817  *   $my_subtheme->includeOnce('file.inc', 'some/other/path');
818  * @endcode
819  *
820  * @see \Drupal\bootstrap\Theme::includeOnce()
821  * @see \Drupal\bootstrap\Bootstrap::getTheme()
822  */
823 function bootstrap_include($theme, $path) {
824   Bootstrap::deprecated();
825   $theme = Bootstrap::getTheme($theme);
826   $parts = explode('/', $path);
827   $file = array_pop($parts);
828   $dir = implode('/', $parts);
829   $theme->includeOnce($file, $dir);
830 }
831
832 /**
833  * Retrieves a setting for the current theme or for a given theme.
834  *
835  * @param string $name
836  *   The name of the setting to be retrieved.
837  * @param string $theme
838  *   The name of a given theme; defaults to the currently active theme.
839  * @param string $prefix
840  *   The prefix used on the $name of the setting, this will be appended with
841  *   "_" automatically if set.
842  *
843  * @return mixed
844  *   The value of the requested setting, NULL if the setting does not exist.
845  *
846  * @deprecated Will be removed in a future release.
847  *
848  * @code
849  *   // Before ("button_colorize" and "my_subtheme_custom_option").
850  *   $colorize = bootstrap_setting('button_colorize', 'my_subtheme');
851  *   $custom_option = bootstrap_setting('custom_option', 'my_subtheme', 'my_subtheme');
852  *
853  *   // After ("button_colorize" and "my_subtheme_custom_option").
854  *   use Drupal\bootstrap\Bootstrap;
855  *   $my_subtheme = Bootstrap::getTheme('my_subtheme');
856  *   $my_subtheme->getSetting('button_colorize');
857  *   $my_subtheme->getSetting('my_subtheme_custom_option');
858  * @endcode
859  *
860  * @see \Drupal\bootstrap\Theme::getSetting()
861  * @see \Drupal\bootstrap\Bootstrap::getTheme()
862  */
863 function bootstrap_setting($name, $theme = NULL, $prefix = 'bootstrap') {
864   Bootstrap::deprecated();
865   $theme = Bootstrap::getTheme($theme);
866   $prefix = $prefix !== 'bootstrap' && !empty($prefix) ? $prefix . '_' : '';
867   return $theme->getSetting($prefix . $name);
868 }