ThemeInitializationInterface.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace Drupal\Core\Theme;
  3. use Drupal\Core\Extension\Extension;
  4. /**
  5. * Defines an interface which contain theme initialization logic.
  6. */
  7. interface ThemeInitializationInterface {
  8. /**
  9. * Initializes a given theme.
  10. *
  11. * This loads the active theme, for example include its engine file.
  12. *
  13. * @param string $theme_name
  14. * The machine name of the theme.
  15. *
  16. * @return \Drupal\Core\Theme\ActiveTheme
  17. * An active theme object instance for the given theme.
  18. */
  19. public function initTheme($theme_name);
  20. /**
  21. * Builds an active theme object.
  22. *
  23. * @param string $theme_name
  24. * The machine name of the theme.
  25. *
  26. * @return \Drupal\Core\Theme\ActiveTheme
  27. * An active theme object instance for the given theme.
  28. *
  29. * @throws \Drupal\Core\Theme\MissingThemeDependencyException
  30. * Thrown when base theme for installed theme is not installed.
  31. */
  32. public function getActiveThemeByName($theme_name);
  33. /**
  34. * Loads a theme, so it is ready to be used.
  35. *
  36. * Loading a theme includes loading and initializing the engine,
  37. * each base theme and its engines.
  38. *
  39. * @param \Drupal\Core\Theme\ActiveTheme $active_theme
  40. * The theme to load.
  41. */
  42. public function loadActiveTheme(ActiveTheme $active_theme);
  43. /**
  44. * Builds up the active theme object from extensions.
  45. *
  46. * @param \Drupal\Core\Extension\Extension $theme
  47. * The theme extension object.
  48. * @param \Drupal\Core\Extension\Extension[] $base_themes
  49. * An array of extension objects of base theme and its bases. It is ordered
  50. * by 'next parent first', meaning the top level of the chain will be first.
  51. *
  52. * @return \Drupal\Core\Theme\ActiveTheme
  53. * The active theme instance for the passed in $theme.
  54. */
  55. public function getActiveTheme(Extension $theme, array $base_themes = []);
  56. }