public function disable() { $payment = $this->Payment(); $payment->active = 0; $payment->save(); return parent::disable(); }
/** * Disables the plugin * * @throws Exception * @return boolean */ public function disable() { try { $payment[0] = 'paymillcc'; $payment[1] = 'paymilldebit'; foreach ($payment as $key) { $currentPayment = $this->Payments()->findOneBy(array('name' => $key)); if ($currentPayment) { $currentPayment->setActive(false); } } } catch (Exception $exception) { throw new Exception("Cannot disable payment: " . $exception->getMessage()); } return parent::disable(); }
/** * Registers a plugin in the collection. * If $removeData is set to false the plugin data will not be removed. * * @param Shopware_Components_Plugin_Bootstrap $bootstrap * @param bool $removeData * @return bool * @throws Exception */ public function uninstallPlugin(Shopware_Components_Plugin_Bootstrap $bootstrap, $removeData = true) { /** @var \Shopware\Components\Model\ModelManager $em */ $em = $this->Application()->Models(); /** @var \Enlight_Components_Db_Adapter_Pdo_Mysql $db */ $db = $this->Application()->Db(); $id = $this->getPluginId($bootstrap->getName()); $plugin = $em->find('Shopware\\Models\\Plugin\\Plugin', $id); $this->Application()->Events()->notify('Shopware_Plugin_PreUninstall', array('subject' => $this, 'plugin' => $bootstrap, 'removeData' => $removeData)); $result = $bootstrap->disable(); $capabilities = $bootstrap->getCapabilities(); $capabilities['secureUninstall'] = !empty($capabilities['secureUninstall']); $success = is_bool($result) ? $result : !empty($result['success']); if (!$success) { return $result; } $this->Application()->Events()->notify('Shopware_Plugin_PostUninstall', array('subject' => $this, 'plugin' => $bootstrap, 'removeData' => $removeData)); if ($removeData) { $result = $bootstrap->uninstall(); } elseif ($capabilities['secureUninstall']) { $result = $bootstrap->secureUninstall(); } else { throw new \Exception('Plugin does not support secure uninstall.'); } $this->Application()->Events()->notify('Shopware_Plugin_PostUninstall', array('subject' => $this, 'plugin' => $bootstrap, 'removeData' => $removeData)); $success = is_bool($result) ? $result : !empty($result['success']); if (!$success) { return $result; } $plugin->setInstalled(null); $plugin->setActive(false); $em->flush($plugin); // Remove event subscribers $sql = 'DELETE FROM `s_core_subscribes` WHERE `pluginID`=?'; $db->query($sql, array($id)); // Remove crontab-entries $sql = 'DELETE FROM `s_crontab` WHERE `pluginID`=?'; $db->query($sql, array($id)); // Remove form $this->removeForm($bootstrap, $removeData); // Remove snippets if ($capabilities['secureUninstall']) { $bootstrap->removeSnippets($removeData); } else { $bootstrap->removeSnippets(true); } // Remove menu-entry $query = 'DELETE FROM Shopware\\Models\\Menu\\Menu m WHERE m.pluginId = ?0'; $query = $em->createQuery($query); $query->execute(array($id)); // Remove templates $query = 'DELETE FROM Shopware\\Models\\Shop\\Template t WHERE t.pluginId = ?0'; $query = $em->createQuery($query); $query->execute(array($id)); // Remove emotion-components $sql = "DELETE s_emotion_element_value, s_emotion_element\n FROM s_emotion_element_value\n RIGHT JOIN s_emotion_element\n ON s_emotion_element.id = s_emotion_element_value.elementID\n INNER JOIN s_library_component\n ON s_library_component.id = s_emotion_element.componentID\n AND s_library_component.pluginID = :pluginId"; $db->query($sql, array(':pluginId' => $id)); $sql = "DELETE s_library_component_field, s_library_component\n FROM s_library_component_field\n INNER JOIN s_library_component\n ON s_library_component.id = s_library_component_field.componentID\n AND s_library_component.pluginID = :pluginId"; $db->query($sql, array(':pluginId' => $id)); $this->removePluginWidgets($id); return $result; }
/** * Registers a plugin in the collection. * * @param Shopware_Components_Plugin_Bootstrap $plugin * @return bool */ public function uninstallPlugin(Shopware_Components_Plugin_Bootstrap $plugin) { $result = $plugin->disable(); $success = is_bool($result) ? $result : !empty($result['success']); if($success) { $result = $plugin->uninstall(); $success = is_bool($result) ? $result : !empty($result['success']); } if ($success) { $id = $plugin->getId(); $data = array( 'installation_date' => NULL, 'active' => 0 ); $this->Application()->Db()->update('s_core_plugins', $data, array('id=?' => $id)); $sql = 'DELETE FROM `s_core_subscribes` WHERE `pluginID`=?'; $this->Application()->Db()->query($sql, array($id)); $sql = 'DELETE FROM `s_crontab` WHERE `pluginID`=?'; $this->Application()->Db()->query($sql, array($id)); /** @var $em Shopware\Components\Model\ModelManager */ $em = $this->Application()->Models(); if($plugin->hasForm()) { $form = $plugin->Form(); if($form->getId()) { $em->remove($form); } else { $em->detach($form); } $em->flush(); } $query = 'DELETE FROM Shopware\Models\Menu\Menu m WHERE m.pluginId = ?0'; $query = $em->createQuery($query); $query->execute(array($id)); $query = 'DELETE FROM Shopware\Models\Shop\Template t WHERE t.pluginId = ?0'; $query = $em->createQuery($query); $query->execute(array($id)); } return $result; }
/** * Registers a plugin in the collection. * * @param Shopware_Components_Plugin_Bootstrap $bootstrap * @return bool */ public function uninstallPlugin(Shopware_Components_Plugin_Bootstrap $bootstrap) { /** @var \Shopware\Components\Model\ModelManager $em */ $em = $this->Application()->Models(); /** @var \Enlight_Components_Db_Adapter_Pdo_Mysql $db */ $db = $this->Application()->Db(); $id = $this->getPluginId($bootstrap->getName()); $plugin = $em->find('Shopware\\Models\\Plugin\\Plugin', $id); $this->Application()->Events()->notify('Shopware_Plugin_PreUninstall', array('subject' => $this, 'plugin' => $bootstrap)); $result = $bootstrap->disable(); $success = is_bool($result) ? $result : !empty($result['success']); if ($success) { $result = $bootstrap->uninstall(); $this->Application()->Events()->notify('Shopware_Plugin_PostUninstall', array('subject' => $this, 'plugin' => $bootstrap)); $success = is_bool($result) ? $result : !empty($result['success']); } if ($success) { $plugin->setInstalled(null); $plugin->setActive(false); $em->flush($plugin); // Remove event subscribers $sql = 'DELETE FROM `s_core_subscribes` WHERE `pluginID`=?'; $db->query($sql, array($id)); // Remove crontab-entries $sql = 'DELETE FROM `s_crontab` WHERE `pluginID`=?'; $db->query($sql, array($id)); // Remove form if ($bootstrap->hasForm()) { $form = $bootstrap->Form(); if ($form->getId()) { $em->remove($form); } else { $em->detach($form); } $em->flush(); } // Remove menu-entry $query = 'DELETE FROM Shopware\\Models\\Menu\\Menu m WHERE m.pluginId = ?0'; $query = $em->createQuery($query); $query->execute(array($id)); // Remove templates $query = 'DELETE FROM Shopware\\Models\\Shop\\Template t WHERE t.pluginId = ?0'; $query = $em->createQuery($query); $query->execute(array($id)); // Remove emotion-components $sql = "DELETE s_emotion_element\n FROM s_emotion_element\n INNER JOIN s_library_component\n ON s_library_component.id = s_emotion_element.componentID\n AND s_library_component.pluginID = :pluginId"; $db->query($sql, array(':pluginId' => $id)); $sql = "DELETE s_library_component_field, s_library_component\n FROM s_library_component_field\n INNER JOIN s_library_component\n ON s_library_component.id = s_library_component_field.componentID\n AND s_library_component.pluginID = :pluginId"; $db->query($sql, array(':pluginId' => $id)); $this->removePluginWidgets($id); } return $result; }