file ProviderInterface.php

Namespace

Drupal\bootstrap\Plugin\Provider
  1. <?php
  2. namespace Drupal\bootstrap\Plugin\Provider;
  3. use Drupal\Component\Plugin\DerivativeInspectionInterface;
  4. use Drupal\Component\Plugin\PluginInspectionInterface;
  5. /**
  6. * ProviderInterface.
  7. *
  8. * @ingroup plugins_provider
  9. */
  10. interface ProviderInterface extends PluginInspectionInterface, DerivativeInspectionInterface {
  11. /**
  12. * Defines the "assets" cache type.
  13. *
  14. * @var string
  15. */
  16. const CACHE_ASSETS = 'assets';
  17. /**
  18. * Defines the "library" cache type.
  19. *
  20. * @var string
  21. */
  22. const CACHE_LIBRARY = 'library';
  23. /**
  24. * Defines the "themes" cache type.
  25. *
  26. * @var string
  27. */
  28. const CACHE_THEMES = 'themes';
  29. /**
  30. * Defines the "versions" cache type.
  31. *
  32. * @var string
  33. */
  34. const CACHE_VERSIONS = 'versions';
  35. /**
  36. * Defines the "forever" time-to-live (TTL) value.
  37. *
  38. * @var int
  39. */
  40. const TTL_FOREVER = -1;
  41. /**
  42. * Defines the "never" time-to-live (TTL) value.
  43. *
  44. * @var int
  45. */
  46. const TTL_NEVER = 0;
  47. /**
  48. * Defines the "one day" time-to-live (TTL) value.
  49. *
  50. * @var int
  51. */
  52. const TTL_ONE_DAY = 86400;
  53. /**
  54. * Defines the "one week" time-to-live (TTL) value.
  55. *
  56. * @var int
  57. */
  58. const TTL_ONE_WEEK = 604800;
  59. /**
  60. * Defines the "one month" time-to-live (TTL) value.
  61. *
  62. * @var int
  63. */
  64. const TTL_ONE_MONTH = 2630000;
  65. /**
  66. * Defines the "three months" time-to-live (TTL) value.
  67. *
  68. * @var int
  69. */
  70. const TTL_THREE_MONTHS = 7776000;
  71. /**
  72. * Defines the "six months" time-to-live (TTL) value.
  73. *
  74. * @var int
  75. */
  76. const TTL_SIX_MONTHS = 15780000;
  77. /**
  78. * Defines the "one year" time-to-live (TTL) value.
  79. *
  80. * @var int
  81. */
  82. const TTL_ONE_YEAR = 31536000;
  83. /**
  84. * Alters the framework library.
  85. *
  86. * @param array $framework
  87. * The framework library, passed by reference.
  88. */
  89. public function alterFrameworkLibrary(array &$framework);
  90. /**
  91. * Retrieves the cache time-to-live (TTL) value.
  92. *
  93. * @param string $type
  94. * The type of cache TTL value. Can be one of the following types:
  95. * - \Drupal\bootstrap\Plugin\Provider\ProviderInterface::CACHE_ASSETS
  96. * - \Drupal\bootstrap\Plugin\Provider\ProviderInterface::CACHE_LIBRARY
  97. * - \Drupal\bootstrap\Plugin\Provider\ProviderInterface::CACHE_THEMES
  98. * - \Drupal\bootstrap\Plugin\Provider\ProviderInterface::CACHE_VERSIONS
  99. * If an invalid type was specified, the resulting TTL value will be 0.
  100. *
  101. * @return int
  102. * The cache TTL value, in seconds.
  103. */
  104. public function getCacheTtl($type);
  105. /**
  106. * Retrieves the assets from the CDN, if any.
  107. *
  108. * @param string $version
  109. * Optional. The version of assets to return. If not set, the setting
  110. * stored in the active theme will be used.
  111. * @param string $theme
  112. * Optional. A specific set of themed assets to return, if any. If not set,
  113. * the setting stored in the active theme will be used.
  114. *
  115. * @return \Drupal\bootstrap\Plugin\Provider\CdnAssets
  116. * A CdnAssets object.
  117. */
  118. public function getCdnAssets($version = NULL, $theme = NULL);
  119. /**
  120. * Retrieves any CDN ProviderException objects triggered during discovery.
  121. *
  122. * Note: this is primarily used as a way to communicate in the UI that
  123. * the discovery of the CDN Provider's assets failed.
  124. *
  125. * @param bool $reset
  126. * Flag indicating whether to remove the Exceptions once they have been
  127. * retrieved.
  128. *
  129. * @return \Drupal\bootstrap\Plugin\Provider\ProviderException[]
  130. * An array of CDN ProviderException objects, if any.
  131. */
  132. public function getCdnExceptions($reset = TRUE);
  133. /**
  134. * Retrieves the currently set CDN Provider theme.
  135. *
  136. * @return string
  137. * The currently set CDN Provider theme.
  138. */
  139. public function getCdnTheme();
  140. /**
  141. * Retrieves the themes supported by the CDN Provider.
  142. *
  143. * @param string $version
  144. * Optional. A specific version of themes to retrieve. If not set, the
  145. * currently set CDN version of the active theme will be used.
  146. *
  147. * @return \Drupal\bootstrap\Plugin\Provider\CdnAssets[]
  148. * An associative array of CDN assets, similar to what is returned in
  149. * \Drupal\bootstrap\Plugin\Provider\ProviderBase::getCdnAssets(), but
  150. * keyed by individual theme names.
  151. */
  152. public function getCdnThemes($version = NULL);
  153. /**
  154. * Retrieves the currently set CDN Provider version.
  155. *
  156. * @return string
  157. * The currently set CDN Provider version.
  158. */
  159. public function getCdnVersion();
  160. /**
  161. * Retrieves the versions supported by the CDN Provider.
  162. *
  163. * @return array|false
  164. * An associative array of versions, also keyed by the version.
  165. */
  166. public function getCdnVersions();
  167. /**
  168. * Retrieves the provider description.
  169. *
  170. * @return string
  171. * The provider description.
  172. */
  173. public function getDescription();
  174. /**
  175. * Retrieves the provider human-readable label.
  176. *
  177. * @return string
  178. * The provider human-readable label.
  179. */
  180. public function getLabel();
  181. /**
  182. * Removes any cached data the CDN Provider may have.
  183. */
  184. public function resetCache();
  185. /**
  186. * Indicates whether the CDN Provider supports themes.
  187. *
  188. * @return bool
  189. * TRUE or FALSE
  190. */
  191. public function supportsThemes();
  192. /**
  193. * Indicates whether the CDN Provider supports versions.
  194. *
  195. * @return bool
  196. * TRUE or FALSE
  197. */
  198. public function supportsVersions();
  199. /**
  200. * Tracks any newly generated CDN exceptions generated during a callable.
  201. *
  202. * @param callable $callable
  203. * The callback to execute.
  204. *
  205. * @return \Drupal\bootstrap\Plugin\Provider\ProviderException[]
  206. * An array of newly generated ProviderException objects, if any.
  207. */
  208. public function trackCdnExceptions(callable $callable);
  209. /****************************************************************************
  210. *
  211. * Deprecated methods
  212. *
  213. ***************************************************************************/
  214. /**
  215. * Retrieves the API URL if set.
  216. *
  217. * @return string
  218. * The API URL.
  219. *
  220. * @deprecated in 8.x-3.18, will be removed in a future release. There is no
  221. * replacement for this functionality.
  222. */
  223. public function getApi();
  224. /**
  225. * Retrieves Provider assets for the active provider, if any.
  226. *
  227. * @param string|array $types
  228. * The type of asset to retrieve: "css" or "js", defaults to an array
  229. * array containing both if not set.
  230. *
  231. * @return array
  232. * If $type is a string or an array with only one (1) item in it, the
  233. * assets are returned as an indexed array of files. Otherwise, an
  234. * associative array is returned keyed by the type.
  235. *
  236. * @deprecated in 8.x-3.18, will be removed in a future release.
  237. *
  238. * @see \Drupal\bootstrap\Plugin\Provider\ProviderInterface::getCdnAssets()
  239. */
  240. public function getAssets($types = NULL);
  241. /**
  242. * Retrieves the themes supported by the CDN Provider.
  243. *
  244. * @return array
  245. * An array of themes. If the CDN Provider does not support any it will
  246. * just be an empty array.
  247. *
  248. * @deprecated in 8.x-3.18, will be removed in a future release.
  249. *
  250. * @see \Drupal\bootstrap\Plugin\Provider\ProviderInterface::getCdnThemes()
  251. */
  252. public function getThemes();
  253. /**
  254. * Retrieves the versions supported by the CDN Provider.
  255. *
  256. * @return array
  257. * An array of versions. If the CDN Provider does not support any it will
  258. * just be an empty array.
  259. *
  260. * @deprecated in 8.x-3.18, will be removed in a future release.
  261. *
  262. * @see \Drupal\bootstrap\Plugin\Provider\ProviderInterface::getCdnVersions()
  263. */
  264. public function getVersions();
  265. /**
  266. * Flag indicating that the API data parsing failed.
  267. *
  268. * @return bool
  269. * TRUE or FALSE
  270. *
  271. * @deprecated in 8.x-3.18, will be removed in a future release. There is no
  272. * 1:1 replacement for this functionality.
  273. *
  274. * @see \Drupal\bootstrap\Plugin\Provider\ProviderInterface::getCdnExceptions()
  275. */
  276. public function hasError();
  277. /**
  278. * Flag indicating that the API data was manually imported.
  279. *
  280. * @return bool
  281. * TRUE or FALSE
  282. *
  283. * @deprecated in 8.x-3.18, will be removed in a future release. There is no
  284. * replacement for this functionality.
  285. */
  286. public function isImported();
  287. /**
  288. * Processes the provider plugin definition upon discovery.
  289. *
  290. * @param array $definition
  291. * The provider plugin definition.
  292. * @param string $plugin_id
  293. * The plugin identifier.
  294. *
  295. * @deprecated in 8.x-3.18, will be removed in a future release. There is no
  296. * replacement for this functionality.
  297. */
  298. public function processDefinition(array &$definition, $plugin_id);
  299. /**
  300. * Processes the provider plugin definition upon discovery.
  301. *
  302. * @param array $json
  303. * The JSON data retrieved from the API request.
  304. * @param array $definition
  305. * The provider plugin definition.
  306. *
  307. * @deprecated in 8.x-3.18, will be removed in a future release. There is no
  308. * replacement for this functionality.
  309. */
  310. public function processApi(array $json, array &$definition);
  311. }

Interfaces

Name Description
ProviderInterface ProviderInterface.