public function __construct()
{
$themes = Kernel::getService('em')->getRepository('RZ\\Roadiz\\Core\\Entities\\Theme')->findAll();
$choices = [];
$finder = new Finder();
// Extracting the PHP files from every Theme folder
$iterator = $finder->followLinks()->files()->name('config.yml')->depth(1)->in(ROADIZ_ROOT . '/themes');
// And storing it into an array, used in the form
foreach ($iterator as $file) {
$data = Yaml::parse($file->getPathname());
$classname = '\\Themes\\' . $data['themeDir'] . "\\" . $data['themeDir'] . "App";
/*
* Parsed file is not or does not contain any PHP Class
* Bad Theme !
*/
$choices[$classname] = $data['name'];
}
foreach ($themes as $theme) {
if (array_key_exists($theme->getClassName(), $choices)) {
unset($choices[$theme->getClassName()]);
}
if (array_key_exists(Kernel::INSTALL_CLASSNAME, $choices)) {
unset($choices[Kernel::INSTALL_CLASSNAME]);
}
}
$this->choices = $choices;
}