Révision 3753f249
Ajouté par Assos Assos il y a plus de 10 ans
htmltest/sites/all/modules/libraries/libraries.api.php | ||
---|---|---|
30 | 30 |
* changes of implementing modules and to support different versions of a |
31 | 31 |
* library simultaneously (though only one version can be installed per |
32 | 32 |
* site). A valid use-case is an external library whose version cannot be |
33 |
* determined programatically. |
|
33 |
* determined programmatically. Either 'version' or 'version callback' (or |
|
34 |
* 'version arguments' in case libraries_get_version() is being used as a |
|
35 |
* version callback) must be declared. |
|
34 | 36 |
* - version callback: (optional) The name of a function that detects and |
35 | 37 |
* returns the full version string of the library. The first argument is |
36 | 38 |
* always $library, an array containing all library information as described |
... | ... | |
38 | 40 |
* arguments, either as a single $options parameter or as multiple |
39 | 41 |
* parameters, which correspond to the two ways to specify the argument |
40 | 42 |
* values (see 'version arguments'). Defaults to libraries_get_version(). |
41 |
* - version arguments: A list of arguments to pass to the version callback. |
|
42 |
* Version arguments can be declared either as an associative array whose |
|
43 |
* keys are the argument names or as an indexed array without specifying |
|
44 |
* keys. If declared as an associative array, the arguments get passed to |
|
45 |
* the version callback as a single $options parameter whose keys are the |
|
46 |
* argument names (i.e. $options is identical to the specified array). If |
|
47 |
* declared as an indexed array, the array values get passed to the version |
|
48 |
* callback as seperate arguments in the order they were declared. The |
|
49 |
* default version callback libraries_get_version() expects a single, |
|
50 |
* associative array with named keys: |
|
51 |
* - file: The filename to parse for the version, relative to the library |
|
52 |
* path. For example: 'docs/changelog.txt'. |
|
43 |
* Unless 'version' is declared or libraries_get_version() is being used as |
|
44 |
* a version callback, 'version callback' must be declared. In the latter |
|
45 |
* case, however, 'version arguments' must be declared in the specified way. |
|
46 |
* - version arguments: (optional) A list of arguments to pass to the version |
|
47 |
* callback. Version arguments can be declared either as an associative |
|
48 |
* array whose keys are the argument names or as an indexed array without |
|
49 |
* specifying keys. If declared as an associative array, the arguments get |
|
50 |
* passed to the version callback as a single $options parameter whose keys |
|
51 |
* are the argument names (i.e. $options is identical to the specified |
|
52 |
* array). If declared as an indexed array, the array values get passed to |
|
53 |
* the version callback as separate arguments in the order they were |
|
54 |
* declared. The default version callback libraries_get_version() expects a |
|
55 |
* single, associative array with named keys: |
|
56 |
* - file: The filename to parse for the version, relative to the path |
|
57 |
* speficied as the 'library path' property (see above). For example: |
|
58 |
* 'docs/changelog.txt'. |
|
53 | 59 |
* - pattern: A string containing a regular expression (PCRE) to match the |
54 | 60 |
* library version. For example: '@version\s+([0-9a-zA-Z\.-]+)@'. Note |
55 | 61 |
* that the returned version is not the match of the entire pattern (i.e. |
... | ... | |
60 | 66 |
* - cols: (optional) The maximum number of characters per line to take into |
61 | 67 |
* account. Defaults to 200. In case of minified or compressed files, this |
62 | 68 |
* prevents reading the entire file into memory. |
69 |
* Defaults to an empty array. 'version arguments' must be specified unless |
|
70 |
* 'version' is declared or the specified 'version callback' does not |
|
71 |
* require any arguments. The latter might be the case with a |
|
72 |
* library-specific version callback, for example. |
|
63 | 73 |
* - files: An associative array of library files to load. Supported keys are: |
64 | 74 |
* - js: A list of JavaScript files to load, using the same syntax as Drupal |
65 | 75 |
* core's hook_library(). |
... | ... | |
100 | 110 |
* available or not. The first argument is always $library, an array |
101 | 111 |
* containing all library information as described here. The second |
102 | 112 |
* argument is always a string containing the variant name. There are two |
103 |
* ways to declare the variant callback's additinal arguments, either as a |
|
113 |
* ways to declare the variant callback's additional arguments, either as a
|
|
104 | 114 |
* single $options parameter or as multiple parameters, which correspond |
105 | 115 |
* to the two ways to specify the argument values (see 'variant |
106 |
* arguments'). If ommitted, the variant is expected to always be
|
|
116 |
* arguments'). If omitted, the variant is expected to always be |
|
107 | 117 |
* available. |
108 | 118 |
* - variant arguments: A list of arguments to pass to the variant callback. |
109 | 119 |
* Variant arguments can be declared either as an associative array whose |
... | ... | |
112 | 122 |
* the variant callback as a single $options parameter whose keys are the |
113 | 123 |
* argument names (i.e. $options is identical to the specified array). If |
114 | 124 |
* declared as an indexed array, the array values get passed to the |
115 |
* variant callback as seperate arguments in the order they were declared.
|
|
125 |
* variant callback as separate arguments in the order they were declared.
|
|
116 | 126 |
* Variants can be version-specific (see 'versions'). |
117 | 127 |
* - versions: (optional) An associative array of supported library versions. |
118 | 128 |
* Naturally, libraries evolve over time and so do their APIs. In case a |
... | ... | |
146 | 156 |
* Valid callback groups are: |
147 | 157 |
* - info: Callbacks registered in this group are applied after the library |
148 | 158 |
* information has been retrieved via hook_libraries_info() or info files. |
159 |
* At this point the following additional information is available: |
|
160 |
* - $library['info type']: How the library information was obtained. Can |
|
161 |
* be 'info file', 'module', or 'theme', depending on whether the |
|
162 |
* library information was obtained from an info file, an enabled module |
|
163 |
* or an enabled theme, respectively. |
|
164 |
* Additionally, one of the following three keys is available, depending |
|
165 |
* on the value of $library['info type']. |
|
166 |
* - $library['info file']: In case the library information was obtained |
|
167 |
* from an info file, the URI of the info file. |
|
168 |
* - $library['module']: In case the library was obtained from an enabled |
|
169 |
* module, the name of the providing module. |
|
170 |
* - $library['theme']: In case the library was obtained from an enabled |
|
171 |
* theme, the name of the providing theme. |
|
149 | 172 |
* - pre-detect: Callbacks registered in this group are applied after the |
150 | 173 |
* library path has been determined and before the version callback is |
151 |
* invoked. At this point the following additional information is available: |
|
174 |
* invoked. At this point the following additional information is |
|
175 |
* available: |
|
152 | 176 |
* - $library['library path']: The path on the file system to the library. |
153 | 177 |
* - post-detect: Callbacks registered in this group are applied after the |
154 | 178 |
* library has been successfully detected. At this point the library |
... | ... | |
299 | 323 |
'mymodule_example_libraries_postdetect_callback', |
300 | 324 |
), |
301 | 325 |
// Called before the library's dependencies are loaded. |
302 |
'pre-dependencie-load' => array( |
|
326 |
'pre-dependencies-load' => array(
|
|
303 | 327 |
'mymodule_example_libraries_pre_dependencies_load_callback', |
304 | 328 |
), |
305 | 329 |
// Called before the library is loaded. |
Formats disponibles : Unified diff
Weekly update of contrib modules