ThemeProvider.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\View\Design\Theme;
  7. use Magento\Framework\View\Design\ThemeFactory;
  8. use Magento\Framework\View\Design\ThemeInterface;
  9. /**
  10. * Provide data for theme grid and for theme edit page
  11. */
  12. class ThemeProvider implements \Magento\Framework\View\Design\Theme\ThemeProviderInterface
  13. {
  14. /**
  15. * @var ListInterface
  16. */
  17. private $themeList;
  18. /**
  19. * @var ThemeFactory
  20. */
  21. protected $themeFactory;
  22. /**
  23. * @var ThemeInterface[]
  24. */
  25. private $themes;
  26. /**
  27. * ThemeProvider constructor
  28. *
  29. * @param ListInterface $themeList
  30. * @param ThemeFactory $themeFactory
  31. */
  32. public function __construct(
  33. ListInterface $themeList,
  34. ThemeFactory $themeFactory
  35. ) {
  36. $this->themeList = $themeList;
  37. $this->themeFactory = $themeFactory;
  38. }
  39. /**
  40. * @inheritdoc
  41. */
  42. public function getThemeByFullPath($fullPath)
  43. {
  44. if (!isset($this->themes[$fullPath])) {
  45. $this->themes[$fullPath] = $this->themeList->getThemeByFullPath($fullPath);
  46. }
  47. return $this->themes[$fullPath];
  48. }
  49. /**
  50. * @inheritdoc
  51. * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  52. */
  53. public function getThemeCustomizations(
  54. $area = \Magento\Framework\App\Area::AREA_FRONTEND,
  55. $type = \Magento\Framework\View\Design\ThemeInterface::TYPE_VIRTUAL
  56. ) {
  57. return [];
  58. }
  59. /**
  60. * @inheritdoc
  61. */
  62. public function getThemeById($themeId)
  63. {
  64. return $this->themeFactory->getTheme($themeId);
  65. }
  66. }