Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ViewFactory.php
Go to the documentation of this file.
1 <?php
8 
10 
12 {
16  private $objectManager;
17 
23  public function __construct(ObjectManagerInterface $objectManager)
24  {
25  $this->objectManager = $objectManager;
26  }
27 
35  public function create(array $arguments = [])
36  {
37  $viewConfigArguments = [];
38 
39  if (isset($arguments['themeModel']) && isset($arguments['area'])) {
40  if (!($arguments['themeModel'] instanceof \Magento\Framework\View\Design\ThemeInterface)) {
41  throw new \Magento\Framework\Exception\LocalizedException(
42  new \Magento\Framework\Phrase('%1 doesn\'t implement ThemeInterface', [$arguments['themeModel']])
43  );
44  }
46  $design = $this->objectManager->create(\Magento\Theme\Model\View\Design::class);
47  $design->setDesignTheme($arguments['themeModel'], $arguments['area']);
49  $fileResolver = $this->objectManager->create(
50  \Magento\Framework\Config\FileResolver::class,
51  [
52  'designInterface' => $design,
53  ]
54  );
55  $viewConfigArguments['fileResolver'] = $fileResolver;
56  }
57 
58  return $this->objectManager->create(
59  \Magento\Framework\Config\View::class,
60  $viewConfigArguments
61  );
62  }
63 }
$objectManager
Definition: bootstrap.php:17
$arguments
__construct(ObjectManagerInterface $objectManager)
Definition: ViewFactory.php:23