/** * Contructor * * @param ContainerInterface $container * * @api */ public function __construct(ContainerInterface $container) { $this->container = $container; $this->kernel = $container->get('kernel'); $this->pageTree = $this->container->get('red_kite_cms.page_tree'); $this->activeTheme = $this->container->get('red_kite_cms.active_theme'); $this->theme = $this->activeTheme->getActiveThemeBackend(); }
/** * Constructor * * @param TemplateAssetsManager $templateAssetsManager * @param ActiveThemeInterface $activeTheme * @param TemplateManager $templateManager * @param PageBlocksInterface $pageBlocks * @param FactoryRepositoryInterface $factoryRepository * * @api */ public function __construct(TemplateAssetsManager $templateAssetsManager, ActiveThemeInterface $activeTheme, TemplateManager $templateManager, PageBlocksInterface $pageBlocks, FactoryRepositoryInterface $factoryRepository) { $this->assetsManager = $templateAssetsManager; $this->activeTheme = $activeTheme; $this->theme = $activeTheme->getActiveThemeBackend(); $this->templateManager = $templateManager; $this->pageBlocks = $pageBlocks; $this->factoryRepository = $factoryRepository; $this->languageRepository = $this->factoryRepository->createRepository('Language'); $this->pageRepository = $this->factoryRepository->createRepository('Page'); $this->blockRepository = $this->factoryRepository->createRepository('Block'); }
public static function getTemplates(ActiveThemeInterface $activeTheme, ThemesCollection $themes) { $theme = $themes->getTheme($activeTheme->getActiveThemeBackend()->getThemeName()); $templates = array(); foreach ($theme as $template) { $templateName = $template->getTemplateName(); $templates[$templateName] = $templateName; } ksort($templates); $templates = array_merge(array("none" => " "), $templates); return $templates; }
/** * Copies the assets from the development environment to the production one * * @param array $options An array of options */ protected function updateActiveThemeReference(ActiveThemeInterface $activeTheme, array $options) { $configFile = $options["kernelDir"] . '/config/config.yml'; $contents = file_get_contents($configFile); $backendThemeName = $activeTheme->getActiveThemeBackend()->getThemeName(); $frontendThemeName = $activeTheme->getActiveThemeFrontend()->getThemeName(); if ($backendThemeName != $frontendThemeName) { $yaml = new Yaml(); $params = $yaml->parse($contents); $params["assetic"]["bundles"] = array_values(array_diff($params["assetic"]["bundles"], array($frontendThemeName))); $params["assetic"]["bundles"][] = $backendThemeName; $contents = $yaml->dump($params, 4); file_put_contents($configFile, $contents); $activeTheme->writeActiveTheme(null, $backendThemeName); $appKernelFile = $options["kernelDir"] . '/AppKernel.php'; $contents = file_get_contents($appKernelFile); $activeThemeSection = '// RedKiteCms Active Theme' . PHP_EOL; $activeThemeSection .= ' $bundles[] = new RedKiteLabs\\ThemeEngineBundle\\RedKiteLabsThemeEngineBundle();' . PHP_EOL; $activeThemeSection .= sprintf(' $bundles[] = new %s();' . PHP_EOL, get_class($activeTheme->getActiveThemeBackendBundle())); $activeThemeSection .= ' // End RedKiteCms Active Theme' . PHP_EOL; $contents = preg_replace('/\\/\\/ RedKiteCms Active Theme.*?\\/\\/ End RedKiteCms Active Theme/s', $activeThemeSection, $contents); file_put_contents($appKernelFile, $contents); } }