FileResolver.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * Hierarchy config file resolver
  4. *
  5. * Copyright © Magento, Inc. All rights reserved.
  6. * See COPYING.txt for license details.
  7. */
  8. namespace Magento\Email\Model\Template\Config;
  9. use Magento\Framework\Component\ComponentRegistrar;
  10. use Magento\Framework\Component\DirSearch;
  11. use Magento\Framework\Config\FileIteratorFactory;
  12. class FileResolver implements \Magento\Framework\Config\FileResolverInterface
  13. {
  14. /**
  15. * @var \Magento\Framework\Config\FileIteratorFactory
  16. */
  17. protected $iteratorFactory;
  18. /**
  19. * @var DirSearch
  20. */
  21. protected $dirSearch;
  22. /**
  23. * Constructor
  24. *
  25. * @param FileIteratorFactory $iteratorFactory
  26. * @param DirSearch $dirSearch
  27. */
  28. public function __construct(
  29. FileIteratorFactory $iteratorFactory,
  30. DirSearch $dirSearch
  31. ) {
  32. $this->iteratorFactory = $iteratorFactory;
  33. $this->dirSearch = $dirSearch;
  34. }
  35. /**
  36. * {@inheritdoc}
  37. */
  38. public function get($filename, $scope)
  39. {
  40. $iterator = $this->iteratorFactory->create(
  41. $this->dirSearch->collectFiles(ComponentRegistrar::MODULE, 'etc/' . $filename)
  42. );
  43. return $iterator;
  44. }
  45. }