SourceFileGeneratorPool.php 1005 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\View\Asset;
  7. /**
  8. * Class SourceFileGeneratorFactory
  9. *
  10. * @package Magento\Framework\View\Asset
  11. */
  12. class SourceFileGeneratorPool
  13. {
  14. /**
  15. * Renderer Types
  16. *
  17. * @var array
  18. */
  19. private $fileGeneratorTypes;
  20. /**
  21. * Factory constructor
  22. *
  23. * @param SourceFileGeneratorInterface[] $fileGeneratorTypes
  24. */
  25. public function __construct(array $fileGeneratorTypes = [])
  26. {
  27. $this->fileGeneratorTypes = $fileGeneratorTypes;
  28. }
  29. /**
  30. * Create class instance
  31. *
  32. * @param string $generatorType
  33. *
  34. * @return SourceFileGeneratorInterface
  35. */
  36. public function create($generatorType)
  37. {
  38. if (!$this->fileGeneratorTypes[$generatorType]) {
  39. throw new \LogicException('Wrong file generator type!');
  40. }
  41. return $this->fileGeneratorTypes[$generatorType];
  42. }
  43. }