ScopeResolver.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\App;
  7. use Magento\Framework\ObjectManagerInterface;
  8. class ScopeResolver implements ScopeResolverInterface
  9. {
  10. /**
  11. * @var \Magento\Store\Model\StoreManagerInterface
  12. */
  13. protected $objectManager;
  14. /**
  15. * @var ScopeInterface
  16. */
  17. private $defaultScope;
  18. /**
  19. * ScopeResolver constructor
  20. *
  21. * @param ObjectManagerInterface $objectManager
  22. */
  23. public function __construct(ObjectManagerInterface $objectManager)
  24. {
  25. $this->objectManager = $objectManager;
  26. }
  27. /**
  28. * {@inheritdoc}
  29. * @return ScopeDefault
  30. */
  31. public function getScope($scopeId = null)
  32. {
  33. if (!$this->defaultScope) {
  34. $this->defaultScope = $this->objectManager->create(ScopeDefault::class);
  35. }
  36. return $this->defaultScope;
  37. }
  38. /**
  39. * Retrieve a list of available scopes
  40. *
  41. * @return ScopeInterface[]
  42. */
  43. public function getScopes()
  44. {
  45. return [$this->defaultScope];
  46. }
  47. }