Esempio n. 1
0
 /**
  * Return list of layouts found in Theme directory
  * and save it if not found in DB
  *
  * @param Templater_Model_Mapper_Theme $theme
  * @return array
  */
 public function importFromTheme(Mapper\Theme $theme, $import = false)
 {
     $options = $this->config;
     $path = realpath($options->themes->directory . DIRECTORY_SEPARATOR . $theme->getName() . DIRECTORY_SEPARATOR . $options->layout->directory);
     if (empty($path)) {
         return false;
     }
     $layouts = $this->getLayoutsFiles($path);
     $sysmapService = $this->locator->get('sysmap-service');
     $rootNode = $sysmapService->getRootIdentifier();
     if ($import) {
         foreach (array_keys($layouts) as $name) {
             $exist = $this->em->getRepository($this->repoName)->findOneBy(array('theme_id' => $theme->getId(), 'name' => $name));
             if (empty($exist)) {
                 $layout = new Mapper\Layout();
                 $layout->setName($name);
                 $layout->setTheme($theme);
                 $layout->setTitle(ucfirst($name));
                 $layout->setPublished(true);
                 $this->em->persist($layout);
                 if ($name == $options['layout']['default']) {
                     $layPoint = new Mapper\LayoutPoint();
                     $layPoint->setMapId($rootNode->getResourceId());
                     $layPoint->setLayout($layout);
                     $this->em->persist($layPoint);
                 }
             }
         }
     }
     $this->em->flush();
     return $layouts;
 }
Esempio n. 2
0
 /**
  * Save theme object into DB
  * @param Templater_Model_Mapper_Theme $theme
  * @param array $values
  * @return boolean
  */
 public function saveTheme(Mapper\Theme $theme, array $values)
 {
     $theme->fromArray($values);
     $this->em->persist($theme);
     $result = $this->em->flush();
     return $result;
 }