ReadFactory.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\Filesystem\Directory;
  7. use Magento\Framework\Filesystem\DriverPool;
  8. class ReadFactory
  9. {
  10. /**
  11. * Pool of filesystem drivers
  12. *
  13. * @var DriverPool
  14. */
  15. private $driverPool;
  16. /**
  17. * Constructor
  18. *
  19. * @param DriverPool $driverPool
  20. */
  21. public function __construct(DriverPool $driverPool)
  22. {
  23. $this->driverPool = $driverPool;
  24. }
  25. /**
  26. * Create a readable directory
  27. *
  28. * @param string $path
  29. * @param string $driverCode
  30. * @return ReadInterface
  31. */
  32. public function create($path, $driverCode = DriverPool::FILE)
  33. {
  34. $driver = $this->driverPool->getDriver($driverCode);
  35. $factory = new \Magento\Framework\Filesystem\File\ReadFactory(
  36. $this->driverPool
  37. );
  38. return new Read(
  39. $factory,
  40. $driver,
  41. $path,
  42. new PathValidator($driver)
  43. );
  44. }
  45. }