Esempio n. 1
0
 /**
  * Helper function to build the path to the passed plugin.
  * @param Plugin $plugin
  * @return string
  */
 public function getPluginPath(Plugin $plugin)
 {
     $namespace = strtolower($plugin->getNamespace());
     $source = strtolower($plugin->getSource());
     $name = $plugin->getName();
     return $this->rootDir . DIRECTORY_SEPARATOR . 'engine' . DIRECTORY_SEPARATOR . 'Shopware' . DIRECTORY_SEPARATOR . 'Plugins' . DIRECTORY_SEPARATOR . ucfirst($source) . DIRECTORY_SEPARATOR . ucfirst($namespace) . DIRECTORY_SEPARATOR . ucfirst($name);
 }
Esempio n. 2
0
 /**
  * Returns a certain plugin by plugin id.
  *
  * @param \Shopware\Models\Plugin\Plugin $plugin
  * @return Shopware_Components_Plugin_Bootstrap|null
  */
 public function getPluginBootstrap($plugin)
 {
     $namespace = Shopware()->Plugins()->get($plugin->getNamespace());
     if ($namespace === null) {
         return null;
     }
     $plugin = $namespace->get($plugin->getName());
     return $plugin;
 }
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     $plugin = new Plugin();
     $plugin->setName('TestInvalidPlugin');
     $plugin->setSource('Local');
     $plugin->setNamespace('Backend');
     $plugin->setLabel('Invalid Plugin');
     $plugin->setVersion('1.0');
     $manager = Shopware()->Models();
     $manager->persist($plugin);
     $manager->flush($plugin);
 }
Esempio n. 4
0
 /**
  * @param Plugin $plugin
  * @param string $name
  * @param mixed $value
  * @param Shop $shop
  * @throws \Exception
  */
 public function saveConfigElement(Plugin $plugin, $name, $value, Shop $shop = null)
 {
     if ($shop === null) {
         $shopRepository = $this->em->getRepository('Shopware\\Models\\Shop\\Shop');
         $shop = $shopRepository->find($shopRepository->getActiveDefault()->getId());
     }
     $elementRepository = $this->em->getRepository('Shopware\\Models\\Config\\Element');
     $formRepository = $this->em->getRepository('Shopware\\Models\\Config\\Form');
     $valueRepository = $this->em->getRepository('Shopware\\Models\\Config\\Value');
     /** @var $form \Shopware\Models\Config\Form*/
     $form = $formRepository->findOneBy(['pluginId' => $plugin->getId()]);
     /** @var $element \Shopware\Models\Config\Element */
     $element = $elementRepository->findOneBy(['form' => $form, 'name' => $name]);
     if (!$element) {
         throw new \Exception(sprintf('Config element "%s" not found.', $name));
     }
     if ($element->getScope() == 0) {
         // todo prevent subshop updates
     }
     $defaultValue = $element->getValue();
     $valueModel = $valueRepository->findOneBy(['shop' => $shop, 'element' => $element]);
     if (!$valueModel) {
         if ($value == $defaultValue || $value === null) {
             return;
         }
         $valueModel = new Value();
         $valueModel->setElement($element);
         $valueModel->setShop($shop);
         $valueModel->setValue($value);
         $this->em->persist($valueModel);
         $this->em->flush($valueModel);
         return;
     }
     if ($value == $defaultValue || $value === null) {
         $this->em->remove($valueModel);
     } else {
         $valueModel->setValue($value);
     }
     $this->em->flush($valueModel);
 }
Esempio n. 5
0
 /**
  * deactivate httpCache-Plugin
  * @param Plugin $httpCache
  */
 private function deactivateHttpCache($httpCache)
 {
     if (!$httpCache->getActive()) {
         return;
     }
     /**@var $service InstallerService*/
     $service = Shopware()->Container()->get('shopware.plugin_manager');
     $service->deactivatePlugin($httpCache);
 }