ScopeFactory.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\Model\Entity;
  7. use Magento\Framework\ObjectManagerInterface;
  8. /**
  9. * Class ScopeFactory
  10. */
  11. class ScopeFactory
  12. {
  13. /**
  14. * @var ObjectManagerInterface
  15. */
  16. private $objectManager;
  17. /**
  18. * ScopeFactory constructor.
  19. *
  20. * @param ObjectManagerInterface $objectManager
  21. */
  22. public function __construct(
  23. ObjectManagerInterface $objectManager
  24. ) {
  25. $this->objectManager = $objectManager;
  26. }
  27. /**
  28. * @param string $identifier
  29. * @param string $value
  30. * @param ScopeInterface|null $fallback
  31. * @return ScopeInterface
  32. */
  33. public function create($identifier, $value, $fallback = null)
  34. {
  35. return $this->objectManager->create(
  36. ScopeInterface::class,
  37. [
  38. 'identifier' => $identifier,
  39. 'value' => $value,
  40. 'fallback' => $fallback
  41. ]
  42. );
  43. }
  44. }