Exemple #1
0
 /**
  * Configuration plugin action.
  *
  * @param null $plugin
  */
 public function config($plugin = null)
 {
     $plugin = UnionPlugin::aliasToName($plugin);
     $alias = UnionPlugin::nameToAlias($plugin);
     $pluginName = UnionPlugin::getFullName($plugin);
     $isLoaded = CakePlugin::loaded($plugin);
     if ($isLoaded) {
         $configs = $this->Plugins->find()->where(['alias' => $alias])->first();
         if (!$configs) {
             $configs = $this->Plugins->newEntity(['params' => [], 'alias' => $alias, 'name' => $pluginName]);
         }
         if ($this->request->is(['post', 'put'])) {
             $configs = $this->Plugins->patchEntity($configs, $this->request->data);
             if ($result = $this->Plugins->save($configs)) {
                 $this->Flash->success(__d('extensions', 'The settings has been saved.'));
                 return $this->Union->setRedirect(['apply' => ['action' => 'config', $result->alias]]);
             } else {
                 $this->Flash->error(__d('extensions', 'The settings could not be saved. Please, try again.'));
             }
         }
         Event::dispatch($plugin . '.Config.Admin.Controller', $this);
         $this->set('configs', $configs);
         $this->viewBuilder()->templatePath('Admin/Plugin');
         $this->render($plugin . '.config');
     } else {
         throw new MissingPluginException(['plugin' => $plugin]);
     }
 }
Exemple #2
0
 /**
  * Write migration version in database.
  *
  * @param AbstractMigration $migrationObj
  * @return bool|string|void
  */
 protected function _execute(AbstractMigration $migrationObj)
 {
     $version = $migrationObj->getVersion();
     $sqlInsert = sprintf('INSERT INTO %s (' . 'version' . ') VALUES (' . '\'%s\'' . ');', $this->_schemaTableName, $version);
     $this->_adapter->query($sqlInsert);
     $sqlCheck = sprintf('SELECT version FROM %s WHERE version=\'%s\'', $this->_schemaTableName, $version);
     $versionResult = $this->_adapter->fetchRow($sqlCheck);
     $pluginAlias = UnionPlugin::nameToAlias($this->_plugin);
     $pluginName = UnionPlugin::getFullName($this->_plugin);
     if (!empty($versionResult)) {
         return __d('union', 'The version «{0}» of plugin «{1}» has bin success migrated.', sprintf('<strong>%s</strong>', $version), sprintf('<strong>%s</strong>', __d($pluginAlias, $pluginName)));
     }
     return false;
 }