Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / d8 / hook / library_info_build.twig
1 /**
2  * Implements hook_library_info_build().
3  */
4 function {{ machine_name }}_library_info_build() {
5   $libraries = [];
6   // Add a library whose information changes depending on certain conditions.
7   $libraries['mymodule.zombie'] = [
8     'dependencies' => [
9       'core/backbone',
10     ],
11   ];
12   if (Drupal::moduleHandler()->moduleExists('minifyzombies')) {
13     $libraries['mymodule.zombie'] += [
14       'js' => [
15         'mymodule.zombie.min.js' => [],
16       ],
17       'css' => [
18         'base' => [
19           'mymodule.zombie.min.css' => [],
20         ],
21       ],
22     ];
23   }
24   else {
25     $libraries['mymodule.zombie'] += [
26       'js' => [
27         'mymodule.zombie.js' => [],
28       ],
29       'css' => [
30         'base' => [
31           'mymodule.zombie.css' => [],
32         ],
33       ],
34     ];
35   }
36
37   // Add a library only if a certain condition is met. If code wants to
38   // integrate with this library it is safe to (try to) load it unconditionally
39   // without reproducing this check. If the library definition does not exist
40   // the library (of course) not be loaded but no notices or errors will be
41   // triggered.
42   if (Drupal::moduleHandler()->moduleExists('vampirize')) {
43     $libraries['mymodule.vampire'] = [
44       'js' => [
45         'js/vampire.js' => [],
46       ],
47       'css' => [
48         'base' => [
49           'css/vampire.css',
50         ],
51       ],
52       'dependencies' => [
53         'core/jquery',
54       ],
55     ];
56   }
57   return $libraries;
58 }