protected function importTheme($classname, &$text) { $themeFile = $classname; $themeFile = str_replace('\\', '/', $themeFile); $themeFile = str_replace('Themes', 'themes', $themeFile); $themeFile .= ".php"; if (file_exists($themeFile)) { $fixtures = new Fixtures($this->entityManager); $fixtures->installFrontendTheme($classname); $text .= '<info>Theme class “' . $themeFile . '” has been installed…</info>' . PHP_EOL; // install fixtures $array = explode('\\', $classname); $themeRoot = ROADIZ_ROOT . "/themes/" . $array[count($array) - 2]; $yaml = new YamlConfiguration($themeRoot . "/config.yml"); $yaml->load(); $data = $yaml->getConfiguration(); if (false !== $data && isset($data["importFiles"])) { if (isset($data["importFiles"]['roles'])) { foreach ($data["importFiles"]['roles'] as $filename) { \RZ\Roadiz\CMS\Importers\RolesImporter::importJsonFile(file_get_contents($themeRoot . "/" . $filename), $this->entityManager); $text .= ' — <info>Theme file “' . $themeRoot . "/" . $filename . '” has been imported.</info>' . PHP_EOL; } } if (isset($data["importFiles"]['groups'])) { foreach ($data["importFiles"]['groups'] as $filename) { \RZ\Roadiz\CMS\Importers\GroupsImporter::importJsonFile(file_get_contents($themeRoot . "/" . $filename), $this->entityManager); $text .= ' — <info>Theme file “' . $themeRoot . "/" . $filename . '” has been imported..</info>' . PHP_EOL; } } if (isset($data["importFiles"]['settings'])) { foreach ($data["importFiles"]['settings'] as $filename) { \RZ\Roadiz\CMS\Importers\SettingsImporter::importJsonFile(file_get_contents($themeRoot . "/" . $filename), $this->entityManager); $text .= ' — <info>Theme files “' . $themeRoot . "/" . $filename . '” has been imported.</info>' . PHP_EOL; } } if (isset($data["importFiles"]['nodetypes'])) { foreach ($data["importFiles"]['nodetypes'] as $filename) { \RZ\Roadiz\CMS\Importers\NodeTypesImporter::importJsonFile(file_get_contents($themeRoot . "/" . $filename), $this->entityManager); $text .= ' — <info>Theme file “' . $themeRoot . "/" . $filename . '” has been imported.</info>' . PHP_EOL; } } $text .= 'You should do a <info>bin/roadiz orm:schema-tool:update --force</info> to apply your themes into database.' . PHP_EOL; } else { $text .= '<info>Theme class “' . $themeFile . '” has no data to import.</info>' . PHP_EOL; } } else { $text .= '<error>Theme class “' . $themeFile . '” does not exist.</error>' . PHP_EOL; } }