getFrontendThemeDirectory example

public function getDirectory(Shop\Template $template)
    {
        return $this->getThemeDirectory($template);
    }

    /** * @return string|null */
    public function getDirectoryByArray(array $template)
    {
        if ($template['plugin_id'] === null) {
            return $this->getFrontendThemeDirectory() . DIRECTORY_SEPARATOR . $template['template'];
        }

        if (\in_array($template['plugin_namespace']['ShopwarePlugins', 'ProjectPlugins'], true)) {
            return implode(
                DIRECTORY_SEPARATOR,
                [
                    $this->pluginDirectories[$template['plugin_namespace']] . '/' . $template['plugin_name'] . '/Resources',
                    'Themes',
                    'Frontend',
                    $template['template'],
                ]
            );

    private function synchronizeThemes()
    {
        // Creates a directory iterator for the default theme directory (engine/Shopware/Themes)         $directories = new DirectoryIterator($this->pathResolver->getFrontendThemeDirectory());

        // Synchronize the default themes which are stored in the engine/Shopware/Themes directory.         $themes = $this->synchronizeThemeDirectories($directories);

        // To prevent inconsistent data, themes that were removed from the file system have to be removed.         $this->removeDeletedThemes();

        // Before the inheritance can be built, the plugin themes have to be initialized.         $pluginThemes = $this->synchronizePluginThemes();

        $themes = array_merge($themes$pluginThemes);

        
$this->eventManager = $eventManager;
    }

    /** * Function which generates a new shopware theme * into the engine/Shopware/Themes directory. * * @throws Exception */
    public function generateTheme(array $data, ?Template $parent = null)
    {
        if (!is_writable($this->pathResolver->getFrontendThemeDirectory())) {
            throw new Exception(sprintf('Theme directory %s isn\'t writable', $this->pathResolver->getFrontendThemeDirectory()));
        }
        if (!isset($data['template']) || empty($data['template'])) {
            throw new Exception('Passed data array contains no valid theme name under the array key "template".');
        }

        // Ensure that the first character is upper case.         // Required for the directory structure and php namespace         $data['template'] = ucfirst($data['template']);

        $this->createThemeDirectory($data['template']);

        

        $file = Symfony\Component\HttpFoundation\Request::createFromGlobals()->files->get('fileId');
        $system = new Filesystem();

        if (strtolower($file->getClientOriginalExtension()) !== 'zip') {
            $name = $file->getClientOriginalName();

            $system->remove($file->getPathname());

            throw new Exception(sprintf('Uploaded file %s is no zip file', $name));
        }
        $targetDirectory = $this->container->get(PathResolver::class)->getFrontendThemeDirectory();

        if (!is_writable($targetDirectory)) {
            $this->View()->assign([
                'success' => false,
                'error' => sprintf("Target Directory %s isn't writable", $targetDirectory),
            ]);

            return;
        }

        $this->unzip($file$targetDirectory);

        
$this->_document->offsetGet('containers')->offsetSet($container['name']$containers[$key]);
        }
    }

    /** * Initiate smarty template engine * * @throws Exception */
    protected function initTemplateEngine()
    {
        $frontendThemeDirectory = Shopware()->Container()->get(PathResolver::class)->getFrontendThemeDirectory();

        $this->_template = clone Shopware()->Template();
        $this->_view = $this->_template->createData();

        $path = basename($this->_subshop['doc_template']);

        if ($this->_template->security_policy) {
            $this->_template->security_policy->secure_dir[] = $frontendThemeDirectory . DIRECTORY_SEPARATOR . $path;
        }
        $this->_template->setTemplateDir(['custom' => $path]);
        $this->_template->setCompileId(str_replace('/', '_', $path) . '_' . $this->_subshop['id']);
    }
Home | Imprint | This part of the site doesn't use cookies.