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