WriteFactory.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 WriteFactory
  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 writable directory
  27. *
  28. * @param string $path
  29. * @param string $driverCode
  30. * @param int $createPermissions
  31. * @return \Magento\Framework\Filesystem\Directory\Write
  32. */
  33. public function create($path, $driverCode = DriverPool::FILE, $createPermissions = null)
  34. {
  35. $driver = $this->driverPool->getDriver($driverCode);
  36. $factory = new \Magento\Framework\Filesystem\File\WriteFactory(
  37. $this->driverPool
  38. );
  39. return new Write(
  40. $factory,
  41. $driver,
  42. $path,
  43. $createPermissions,
  44. new PathValidator($driver)
  45. );
  46. }
  47. }