Exemplo n.º 1
0
 /**
  * Test case
  */
 public function testConfigFileWrite()
 {
     $adapter = new Enlight_Config_Adapter_DbTable(array('automaticSerialization' => true, 'namePrefix' => 'config_', 'nameColumn' => 'name', 'db' => $this->db));
     $config = new Enlight_Config('test', array('adapter' => $adapter, 'section' => 'test', 'allowModifications' => true));
     $config->set('test', 1)->write();
     $config = new Enlight_Config('test', array('adapter' => $adapter));
     $this->assertEquals(1, $config->get('test'));
 }
Exemplo n.º 2
0
 /**
  * Constructor method
  *
  * @param $name
  * @param Enlight_Config|null $info
  */
 public function __construct($name, $info = null)
 {
     $this->info = new Enlight_Config($this->getInfo(), true);
     if ($info instanceof Enlight_Config) {
         $info->setAllowModifications(true);
         $updateVersion = null;
         $updateSource = null;
         if ($info->get('version') < $this->info->get('version')) {
             $updateVersion = $this->info->get('version');
             $updateSource = $this->info->get('source');
         }
         $this->info->merge($info);
         if ($updateVersion !== null) {
             $this->info->set('updateVersion', $updateVersion);
             $this->info->set('updateSource', $updateSource);
         }
     }
     $this->info->set('capabilities', $this->getCapabilities());
     parent::__construct($name);
 }
Exemplo n.º 3
0
 /**
  * Test case
  */
 public function testConfigDirtyFields()
 {
     $config = new Enlight_Config(array(), true);
     $config->set('test', true);
     $this->assertEquals(array('test'), $config->getDirtyFields());
     $config->resetDirtyFields();
     $this->assertArrayCount(0, $config->getDirtyFields());
     $config->setDirtyFields(array('test'));
     $this->assertEquals(array('test'), $config->getDirtyFields());
 }
Exemplo n.º 4
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;
 }
 public function testClientAction()
 {
     $this->get('paypalClient');
     $config = $this->Request()->getParams();
     $config = new \Enlight_Config($config, true);
     // Test timeout
     $timeout = ($config->get('paypalTimeout') ?: 20) * 0.25;
     $config->set('paypalTimeout', $timeout);
     /** @var Zend_Http_Client|Client|RestClient $client */
     $client = null;
     try {
         $client = new Client($config, true);
         $data = $client->getBalance();
         for ($i = 0; isset($data['L_AMT' . $i]); $i++) {
             unset($data['L_AMT' . $i], $data['L_CURRENCYCODE' . $i]);
         }
         unset($data['VERSION']);
         if (isset($data['L_ERRORCODE0'])) {
             $data['code'] = $data['L_ERRORCODE0'];
             $data['message'] = $this->formatErrorMessage($data);
             unset($data['L_ERRORCODE0'], $data['L_SHORTMESSAGE0'], $data['L_LONGMESSAGE0'], $data['L_SEVERITYCODE0']);
         }
         if ($config->get('paypalClientId', false) && $data['ACK'] == 'Success') {
             $client = new RestClient($config);
             $data = $client->setAuthToken();
             $data = array('ACK' => 'Success') + $data;
             if (isset($data['access_token'])) {
                 $data['access_token'] = preg_replace('/[A-Z]/', '#', $data['access_token']);
             }
             unset($data['expires_in']);
         }
     } catch (Exception $e) {
         $data = array('code' => $e->getCode(), 'message' => $e->getMessage());
     }
     $data['shopware_version'] = Shopware::VERSION;
     $data['php_version'] = phpversion();
     if ($config->get('paypalCurl', true) && function_exists('curl_version')) {
         $curlVersion = curl_version();
         $data['curl_version'] = $curlVersion['version'];
         $data['system_host'] = $curlVersion['host'];
         $data['ssl_version'] = $curlVersion['ssl_version'];
         $data['libz_version'] = $curlVersion['libz_version'];
     }
     $this->View()->assign($data);
 }
Exemplo n.º 6
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;
    }