5dc43ffdc700714fad11a149a0e69aac727411a3
[yaffs-website] / web / modules / contrib / libraries / src / ExternalLibrary / Asset / MultipleAssetLibraryInterface.php
1 <?php
2
3 namespace Drupal\libraries\ExternalLibrary\Asset;
4
5 use Drupal\libraries\ExternalLibrary\LibraryInterface;
6 use Drupal\libraries\ExternalLibrary\LibraryManagerInterface;
7
8 /**
9  * Provides an interface for external asset libraries with multiple libraries.
10  *
11  * See SingleAssetLibraryInterface for more information on external asset
12  * libraries in general.
13  *
14  * In case an external asset library contains multiple components that should
15  * be loadable independently from each other, Libraries API registers each
16  * library component as a separate library in the core asset library system. The
17  * resulting core library identifier is
18  * 'libraries/[machine_name].[component_name]' where '[machine_name]' is the
19  * Libraries API machine name of the external library and '[component_name]' is
20  * the component name specified by the library definition.
21  *
22  * Thus, assuming that the external library 'bootstrap' has been declared as a
23  * dependency, for example, and it has 'button' and 'form' components, they can
24  * be attached to a render array in the $build variable with the following code:
25  * @code
26  *   $build['#attached']['library'] = [
27  *     'libraries/bootstrap.button',
28  *     'libraries/bootstrap.form',
29  *   ];
30  * @endcode
31  *
32  * @see \Drupal\libraries\ExternalLibrary\Asset\AssetLibraryInterface
33  *
34  * @todo Support loading of source or minified assets.
35  * @todo Document how library dependencies work.
36  */
37 interface MultipleAssetLibraryInterface extends LibraryInterface {
38
39   /**
40    * Separates the library machine name from its component name.
41    *
42    * The period is chosen in alignment with core asset libraries, which are
43    * named, for example, 'core/jquery.once'.
44    */
45   const SEPARATOR = '.';
46
47   /**
48    * Returns a core asset library array structure for this library.
49    *
50    * @param \Drupal\libraries\ExternalLibrary\LibraryManagerInterface $library_manager
51    *   The library manager that can be used to fetch dependencies.
52    *
53    * @return array
54    *
55    * @see \Drupal\libraries\ExternalLibrary\Asset\SingleAssetLibraryTrait
56    *
57    * @throws \Drupal\libraries\ExternalLibrary\Exception\InvalidLibraryDependencyException
58    *
59    * @todo Document the return value.
60    * @todo Reconsider passing the library manager.
61    */
62   public function getAttachableAssetLibraries(LibraryManagerInterface $library_manager);
63
64 }