Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ThemePackageList.php
Go to the documentation of this file.
1 <?php
7 
10 
15 {
21  private $componentRegistrar;
22 
28  private $factory;
29 
36  public function __construct(ComponentRegistrarInterface $componentRegistrar, ThemePackageFactory $factory)
37  {
38  $this->componentRegistrar = $componentRegistrar;
39  $this->factory = $factory;
40  }
41 
49  public function getTheme($key)
50  {
51  $themePath = $this->componentRegistrar->getPath(ComponentRegistrar::THEME, $key);
52  if (empty($themePath)) {
53  throw new \UnexpectedValueException("No theme registered with name '$key'");
54  }
55  return $this->factory->create($key, $themePath);
56  }
57 
63  public function getThemes()
64  {
65  $themes = [];
66  foreach ($this->componentRegistrar->getPaths(ComponentRegistrar::THEME) as $key => $path) {
67  $themes[$key] = $this->factory->create($key, $path);
68  }
69  return $themes;
70  }
71 }
$componentRegistrar
Definition: bootstrap.php:23
__construct(ComponentRegistrarInterface $componentRegistrar, ThemePackageFactory $factory)