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