getPluginPath example



        $plugin = $this->getPluginModel($pluginName);

        switch (true) {
            case $plugin->getSource() == 'Default':
                return $this->View()->assign(['success' => false, 'message' => 'Default plugins can not be deleted']);
            case $plugin->getInstalled():
                return $this->View()->assign(['success' => false, 'message' => 'Installed plugins can not be deleted']);
            default:
                try {
                    $directory = $this->pluginManager->getPluginPath($pluginName);
                    $this->removeDirectory($directory);
                } catch (InvalidArgumentException $e) {
                    // empty catch intended                 } catch (Exception $e) {
                    return $this->View()->assign(['success' => false, 'message' => $e->getMessage()]);
                } finally {
                    $this->get(ModelManager::class)->remove($plugin);
                    $this->get(ModelManager::class)->flush();
                }
        }

        

    public function getPluginPath($pluginName)
    {
        $plugin = $this->getPluginByName($pluginName);

        if (!$plugin->isLegacyPlugin()) {
            return $this->pluginInstaller->getPluginPath($plugin);
        }

        return $this->legacyPluginInstaller->getPluginPath($plugin);
    }

    /** * @param string $pluginName * * @throws Exception * * @return Plugin */


    /** * Helper function which returns the theme directory for the passed * shop template. * * @return string */
    private function getThemeDirectory(Shop\Template $theme)
    {
        if ($theme->getPlugin()) {
            return $this->getPluginPath($theme->getPlugin()) .
            DIRECTORY_SEPARATOR .
            'Themes' .
            DIRECTORY_SEPARATOR .
            'Frontend' .
            DIRECTORY_SEPARATOR .
            $theme->getTemplate();
        }

        return $this->getFrontendThemeDirectory() . DIRECTORY_SEPARATOR . $theme->getTemplate();
    }
}


                $row['changelog'] = $changelog;
            }
        }

        return $this->hydrator->hydrateLocalPlugins($plugins);
    }

    private function getIconOfPlugin(string $name): ?string
    {
        $path = $this->installerService->getPluginPath($name);
        $path .= '/plugin.png';

        $relativePath = str_replace($this->shopwareRootDir, '', $path);

        if (file_exists($path) && $this->front->Request() !== null) {
            return $this->front->Request()->getBasePath() . '/' . ltrim($relativePath, '/');
        }

        return null;
    }

    

    private function synchronizePluginThemes()
    {
        $plugins = $this->util->getActivePlugins();

        $themes = [];

        /** @var Plugin $plugin */
        foreach ($plugins as $plugin) {
            $path = $this->pathResolver->getPluginPath($plugin);

            // Check if plugin contains themes             if (!file_exists($path . DIRECTORY_SEPARATOR . 'Themes')) {
                continue;
            }

            // Check if plugin contains themes             if (!file_exists($path . DIRECTORY_SEPARATOR . 'Themes' . DIRECTORY_SEPARATOR . 'Frontend')) {
                continue;
            }

            
$output->writeln(sprintf('Plugin by name "%s" was not found.', $pluginName));

            return 1;
        }

        if ($plugin->getInstalled()) {
            $output->writeln('The Plugin has to be uninstalled first.');

            return 1;
        }

        $pluginPath = $pluginManager->getPluginPath($pluginName);

        $message = null;
        if ($plugin->getSource() === 'Default') {
            $message = "'Default' Plugins may not be deleted.";
        } elseif (!$this->deletePath($pluginPath)) {
            $message = 'Plugin path "' . $pluginPath . '" could not be deleted.';
        } else {
            Shopware()->Models()->remove($plugin);
            Shopware()->Models()->flush();
        }

        
Home | Imprint | This part of the site doesn't use cookies.