Hallo,
ich habe zwei Wege gefunden, in einem Subscriber zu prüfen, ob ein Plugin aktiv ist oder nicht. Kann mir jemand sagen, welche Lösung die bessere ist und wenn ja, warum?
/**
* @param EventArgs $args
* @throws \Exception
*/
public function onFrontendPostDispatch(EventArgs $args)
{
/** @var \Enlight_Controller_Action $controller */
$controller = $args->get('subject');
$pluginManager = $controller->get('shopware_plugininstaller.plugin_manager');
$pluginName = "NameDesPlugins";
try {
$plugin = $pluginManager->getPluginByName($pluginName);
if ($plugin->getActive()) {
$view->assign($pluginName, true);
}
} catch (\Exception $e) {}
/* ODER SO */
$pluginInstalled = Shopware()->Models()->getRepository(\Shopware\Models\Plugin\Plugin::class)->findOneBy(['name' => $pluginName, 'active' => 1]);
if($pluginInstalled) {
$view->assign($pluginName, true);
}
}