ThemePackage.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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\Config\Theme;
  8. /**
  9. * Value-object for a theme package
  10. */
  11. class ThemePackage
  12. {
  13. /**
  14. * Area
  15. *
  16. * @var string
  17. */
  18. private $area;
  19. /**
  20. * Vendor name
  21. *
  22. * @var string
  23. */
  24. private $vendor;
  25. /**
  26. * Theme name
  27. *
  28. * @var string
  29. */
  30. private $name;
  31. /**
  32. * Theme path key
  33. *
  34. * @var string
  35. */
  36. private $key;
  37. /**
  38. * Full path to the theme
  39. *
  40. * @var string
  41. */
  42. private $path;
  43. /**
  44. * Constructor
  45. *
  46. * @param string $key
  47. * @param string $path
  48. */
  49. public function __construct($key, $path)
  50. {
  51. $keyParts = explode(Theme::THEME_PATH_SEPARATOR, $key);
  52. if (count($keyParts) != 3) {
  53. throw new \UnexpectedValueException(
  54. "Theme's key does not correspond to required format: '<area>/<vendor>/<name>'"
  55. );
  56. }
  57. $this->key = $key;
  58. $this->path = $path;
  59. $this->area = $keyParts[0];
  60. $this->vendor = $keyParts[1];
  61. $this->name = $keyParts[2];
  62. }
  63. /**
  64. * Get area
  65. *
  66. * @return string
  67. */
  68. public function getArea()
  69. {
  70. return $this->area;
  71. }
  72. /**
  73. * Get vendor name
  74. *
  75. * @return string
  76. */
  77. public function getVendor()
  78. {
  79. return $this->vendor;
  80. }
  81. /**
  82. * Get theme name
  83. *
  84. * @return string
  85. */
  86. public function getName()
  87. {
  88. return $this->name;
  89. }
  90. /**
  91. * Get path key
  92. *
  93. * @return string
  94. */
  95. public function getKey()
  96. {
  97. return $this->key;
  98. }
  99. /**
  100. * Get full path
  101. *
  102. * @return string
  103. */
  104. public function getPath()
  105. {
  106. return $this->path;
  107. }
  108. }