/**
  * Synchronizes the site slots with the theme slots
  *
  * @param \RedKiteCms\FilesystemEntity\Page $page
  * @param array $pages
  */
 public function synchronize(Page $page, array $pages)
 {
     if (!$this->configurationHandler->isTheme()) {
         return;
     }
     foreach ($pages as $pageValues) {
         $tokens = explode("_", $pageValues["seo"][0]["language"]);
         $pageOptions = array('page' => $pageValues["name"], 'language' => $tokens[0], 'country' => $tokens[1]);
         $page->render($this->configurationHandler->siteDir(), $pageOptions);
         $this->saveTemplateSlots($page->getPageSlots(), $pageValues["template"]);
     }
     $this->saveTemplateSlots($page->getCommonSlots(), 'base');
 }
 private function createWebsitePages($theme)
 {
     $isTheme = $this->app["red_kite_cms.configuration_handler"]->isTheme();
     $user = null;
     if (!$isTheme) {
         $user = '******';
     }
     $language = "en_GB";
     $pages = $theme->getPages();
     if (null == $pages) {
         $this->registerTwig();
         echo $this->app["twig"]->render('RedKiteCms/Resources/views/Bootstrap/bootstrap.html.twig', array("theme_name" => $theme->getName(), "site_path" => $this->app["red_kite_cms.configuration_handler"]->siteDir()));
         exit;
     }
     $this->app["red_kite_cms.page_collection_manager"]->contributor($user);
     $theme = $this->app["red_kite_cms.theme"];
     $this->app["red_kite_cms.slots_generator"]->generate();
     foreach ($pages as $pageName => $templateName) {
         $page = array("name" => $pageName, "template" => $templateName, "seo" => array(array("permalink" => str_replace('_', '-', strtolower($language)) . "-" . $pageName, "changed_permalinks" => array(), "title" => $pageName . '-title', "description" => $pageName . '-description', "keywords" => $pageName . '-keywords', "sitemap_frequency" => 'monthly', "sitemap_priority" => '0.5', "language" => $language)));
         $this->app["red_kite_cms.page_collection_manager"]->add($theme, $page);
         $page = new Page($this->app["jms.serializer"], new OptionsResolver(), $this->app["red_kite_cms.slot_parser"]);
         $pageOptions = array('page' => $pageName, 'language' => 'en', 'country' => 'GB');
         $page->render($this->app["red_kite_cms.configuration_handler"]->siteDir(), $pageOptions, $user);
         $this->savePermalinks($page->getPageSlots());
         $this->savePermalinks($page->getCommonSlots());
         $this->app["red_kite_cms.permalink_manager"]->save();
     }
     if (!$isTheme) {
         $blockManager = new BlockManagerApprover($this->app["jms.serializer"], new OptionsResolver());
         $this->app["red_kite_cms.deployer"]->contributor('admin')->saveAllPages($blockManager, array('en_GB'));
     }
     $fileSystem = new Filesystem();
     $fileSystem->remove($this->app["red_kite_cms.configuration_handler"]->siteCacheDir());
 }