Exemplo n.º 1
0
 /**
  * Registers a plugin in the collection.
  *
  * @param   Shopware_Components_Plugin_Bootstrap $plugin
  * @return  bool
  */
 public function updatePlugin(Shopware_Components_Plugin_Bootstrap $plugin)
 {
     $this->reloadStorage();
     $name = $plugin->getName();
     $oldVersion = $this->getInfo($name, 'version');
     $newInfo = $plugin->getInfo();
     $newInfo = new Enlight_Config($newInfo, true);
     unset($newInfo->source);
     $this->Application()->Events()->notify('Shopware_Plugin_PreUpdate', array('subject' => $this, 'plugin' => $plugin));
     $result = $plugin->update($oldVersion);
     $success = is_bool($result) ? $result : !empty($result['success']);
     if ($success) {
         $this->Application()->Events()->notify('Shopware_Plugin_PostUpdate', array('subject' => $this, 'plugin' => $plugin));
         $newInfo->set('updateVersion', null);
         $newInfo->set('updateSource', null);
         $newInfo->set('updateDate', Zend_Date::now());
         $plugin->Info()->merge($newInfo);
         $this->registerPlugin($plugin);
         // Save events / Hooks
         $this->write();
         $form = $plugin->Form();
         if ($form->hasElements()) {
             $this->Application()->Models()->persist($form);
         }
         $this->Application()->Models()->flush();
         Shopware()->Container()->get('shopware.snippet_database_handler')->loadToDatabase($plugin->Path() . 'Snippets/');
         Shopware()->Container()->get('shopware.snippet_database_handler')->loadToDatabase($plugin->Path() . 'snippets/');
         Shopware()->Container()->get('shopware.snippet_database_handler')->loadToDatabase($plugin->Path() . 'Resources/snippet/');
         // Clear proxy cache
         $this->Application()->Hooks()->getProxyFactory()->clearCache();
     }
     return $result;
 }
Exemplo n.º 2
0
    /**
     * Registers a plugin in the collection.
     *
     * @param   Shopware_Components_Plugin_Bootstrap $plugin
     * @return  bool
     */
    public function updatePlugin(Shopware_Components_Plugin_Bootstrap $plugin)
    {
        $name = $plugin->getName();
        $oldVersion = $this->getInfo($name, 'version');
        $newInfo = $plugin->getInfo();
        $newInfo = new Enlight_Config($newInfo, true);

        $result = $plugin->update($oldVersion);
        $success = is_bool($result) ? $result : !empty($result['success']);
        if ($success) {
            $newInfo->set('updateVersion', null);
            $newInfo->set('updateSource', null);
            $newInfo->set('updateDate', Zend_Date::now());
            $plugin->Info()->merge($newInfo);
            $this->registerPlugin($plugin);

            // Save events / Hooks
            $this->write();

            $form = $plugin->Form();
            if($form->hasElements()) {
                $this->Application()->Models()->persist($form);
            }
            $this->Application()->Models()->flush();

            // Clear proxy cache
            $this->Application()->Hooks()->getProxyFactory()->clearCache();
        }
        return $result;
    }