예제 #1
0
 /**
  * Helper function which returns all template directories for the
  * passed templates.
  * The function returns an array with all template directories
  * for the inheritance of the passed template.
  *
  * @param \Shopware\Models\Shop\Template $template
  * @return array
  */
 private function getTemplateDirectoriesRecursive(Shop\Template $template)
 {
     $directories = array($this->pathResolver->getDirectory($template));
     if ($template->getParent() instanceof Shop\Template) {
         $directories = array_merge($directories, $this->getTemplateDirectoriesRecursive($template->getParent()));
     }
     return $directories;
 }
예제 #2
0
 /**
  * Returns the theme preview thumbnail.
  *
  * @param \Shopware\Models\Shop\Template $theme
  * @return null|string
  */
 private function getThemeImage(Shop\Template $theme)
 {
     $directory = $this->pathResolver->getDirectory($theme);
     $thumbnail = $directory . '/preview.png';
     if (!file_exists($thumbnail)) {
         return null;
     }
     $thumbnail = file_get_contents($thumbnail);
     return 'data:image/png;base64,' . base64_encode($thumbnail);
 }
예제 #3
0
 /**
  * Removes the database entries for themes which file no more exist.
  */
 private function removeDeletedThemes()
 {
     $themes = $this->repository->createQueryBuilder('templates');
     $themes->where('templates.version = 3')->andWhere('templates.pluginId IS NULL');
     $themes = $themes->getQuery()->getResult(AbstractQuery::HYDRATE_OBJECT);
     /**@var $theme Shop\Template */
     foreach ($themes as $theme) {
         $directory = $this->pathResolver->getDirectory($theme);
         if (!file_exists($directory)) {
             $this->entityManager->remove($theme);
         }
     }
     $this->entityManager->flush();
 }