InfoParserInterface.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. namespace Drupal\Core\Extension;
  3. /**
  4. * Interface for classes that parses Drupal's info.yml files.
  5. */
  6. interface InfoParserInterface {
  7. /**
  8. * Parses Drupal module, theme and profile .info.yml files.
  9. *
  10. * Info files are NOT for placing arbitrary theme and module-specific
  11. * settings. Use Config::get() and Config::set()->save() for that. Info files
  12. * are formatted as YAML. If the 'version' key is set to 'VERSION' in any info
  13. * file, then the value will be substituted with the current version of Drupal
  14. * core.
  15. *
  16. * Information stored in all .info.yml files:
  17. * - name: The real name of the module for display purposes. (Required)
  18. * - description: A brief description of the module.
  19. * - type: whether it is for a module or theme. (Required)
  20. *
  21. * Information stored in a module .info.yml file:
  22. * - dependencies: An array of dependency strings. Each is in the form
  23. * 'project:module (versions)'; with the following meanings:
  24. * - project: (optional) Project shortname, recommended to ensure
  25. * uniqueness, if the module is part of a project hosted on drupal.org.
  26. * If omitted, also omit the : that follows. The project name is currently
  27. * ignored by Drupal core but is used for automated testing.
  28. * - module: (required) Module shortname within the project.
  29. * - (versions): Version information, consisting of one or more
  30. * comma-separated operator/value pairs or simply version numbers, which
  31. * can contain "x" as a wildcard. Examples: (>=8.22, <8.28), (8.x-3.x).
  32. * - package: The name of the package of modules this module belongs to.
  33. *
  34. * See forum.info.yml for an example of a module .info.yml file.
  35. *
  36. * Information stored in a theme .info.yml file:
  37. * - screenshot: Path to screenshot relative to the theme's .info.yml file.
  38. * - engine: Theme engine; typically twig.
  39. * - base theme: Name of a base theme, if applicable.
  40. * - regions: Listed regions.
  41. * - features: Features available.
  42. * - stylesheets: Theme stylesheets.
  43. * - scripts: Theme scripts.
  44. *
  45. * See bartik.info.yml for an example of a theme .info.yml file.
  46. *
  47. * For information stored in a profile .info.yml file see
  48. * install_profile_info().
  49. *
  50. * @param string $filename
  51. * The file we are parsing. Accepts file with relative or absolute path.
  52. *
  53. * @return array
  54. * The info array.
  55. *
  56. * @throws \Drupal\Core\Extension\InfoParserException
  57. * Exception thrown if there is a parsing error or the .info.yml file does
  58. * not contain a required key.
  59. *
  60. * @see install_profile_info()
  61. */
  62. public function parse($filename);
  63. }