Factory.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\View\File;
  7. use Magento\Framework\ObjectManagerInterface;
  8. use Magento\Framework\View\Design\ThemeInterface;
  9. /**
  10. * Factory that produces view file instances
  11. */
  12. class Factory
  13. {
  14. /**
  15. * Object manager
  16. *
  17. * @var ObjectManagerInterface
  18. */
  19. private $objectManager;
  20. /**
  21. * Constructor
  22. *
  23. * @param ObjectManagerInterface $objectManager
  24. */
  25. public function __construct(ObjectManagerInterface $objectManager)
  26. {
  27. $this->objectManager = $objectManager;
  28. }
  29. /**
  30. * Return newly created instance of a view file
  31. *
  32. * @param string $filename
  33. * @param string $module
  34. * @param ThemeInterface|null $theme
  35. * @param bool $isBase
  36. * @return \Magento\Framework\View\File
  37. */
  38. public function create($filename, $module = '', ThemeInterface $theme = null, $isBase = false)
  39. {
  40. return $this->objectManager->create(
  41. \Magento\Framework\View\File::class,
  42. ['filename' => $filename, 'module' => $module, 'theme' => $theme, 'isBase' => $isBase]
  43. );
  44. }
  45. }