Container.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Sales\Model\Order\Email\Container;
  7. use Magento\Framework\App\Config\ScopeConfigInterface;
  8. use Magento\Store\Model\Store;
  9. use Magento\Store\Model\StoreManagerInterface;
  10. /**
  11. * Class Container
  12. *
  13. * @api
  14. * @since 100.0.2
  15. */
  16. abstract class Container implements IdentityInterface
  17. {
  18. /**
  19. * @var StoreManagerInterface
  20. */
  21. protected $storeManager;
  22. /**
  23. * Core store config
  24. *
  25. * @var ScopeConfigInterface
  26. */
  27. protected $scopeConfig;
  28. /**
  29. * @var Store
  30. */
  31. protected $store;
  32. /**
  33. * @var string
  34. */
  35. protected $customerName;
  36. /**
  37. * @var string
  38. */
  39. protected $customerEmail;
  40. /**
  41. * @param ScopeConfigInterface $scopeConfig
  42. * @param StoreManagerInterface $storeManager
  43. */
  44. public function __construct(
  45. ScopeConfigInterface $scopeConfig,
  46. StoreManagerInterface $storeManager
  47. ) {
  48. $this->scopeConfig = $scopeConfig;
  49. $this->storeManager = $storeManager;
  50. }
  51. /**
  52. * Return store configuration value
  53. *
  54. * @param string $path
  55. * @param int $storeId
  56. * @return mixed
  57. */
  58. protected function getConfigValue($path, $storeId)
  59. {
  60. return $this->scopeConfig->getValue(
  61. $path,
  62. \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
  63. $storeId
  64. );
  65. }
  66. /**
  67. * Set current store
  68. *
  69. * @param Store $store
  70. * @return void
  71. */
  72. public function setStore(Store $store)
  73. {
  74. $this->store = $store;
  75. }
  76. /**
  77. * Return store
  78. *
  79. * @return Store
  80. */
  81. public function getStore()
  82. {
  83. //current store
  84. if ($this->store instanceof Store) {
  85. return $this->store;
  86. }
  87. return $this->storeManager->getStore();
  88. }
  89. /**
  90. * Set customer name
  91. *
  92. * @param string $name
  93. * @return void
  94. */
  95. public function setCustomerName($name)
  96. {
  97. $this->customerName = $name;
  98. }
  99. /**
  100. * Set customer email
  101. *
  102. * @param string $email
  103. * @return void
  104. */
  105. public function setCustomerEmail($email)
  106. {
  107. $this->customerEmail = $email;
  108. }
  109. /**
  110. * Return customer name
  111. *
  112. * @return string
  113. */
  114. public function getCustomerName()
  115. {
  116. return $this->customerName;
  117. }
  118. /**
  119. * Return customer email
  120. *
  121. * @return string
  122. */
  123. public function getCustomerEmail()
  124. {
  125. return $this->customerEmail;
  126. }
  127. }