Exemple #1
0
 /**
  * Save plugin parameters and trigger the save events.
  *
  * @param array $data
  * @return bool
  * @see JModelAdmin::save()
  */
 public function onGantry5SaveConfig(array $data)
 {
     $name = 'plg_' . $this->_type . '_' . $this->_name;
     // Initialise variables;
     $dispatcher = JEventDispatcher::getInstance();
     $table = JTable::getInstance('Extension');
     // Include the content plugins for the on save events.
     JPluginHelper::importPlugin('extension');
     // Load the row if saving an existing record.
     $table->load(array('type' => 'plugin', 'folder' => $this->_type, 'element' => $this->_name));
     $params = new Joomla\Registry\Registry($table->params);
     $params->loadArray($data);
     $table->params = $params->toString();
     // Check the data.
     if (!$table->check()) {
         throw new RuntimeException($table->getError());
     }
     // Trigger the onContentBeforeSave event.
     $result = $dispatcher->trigger('onExtensionBeforeSave', array($name, &$table, false));
     if (in_array(false, $result, true)) {
         throw new RuntimeException($table->getError());
     }
     // Store the data.
     if (!$table->store()) {
         throw new RuntimeException($table->getError());
     }
     // Clean the cache.
     \Gantry\Joomla\CacheHelper::cleanPlugin();
     // Trigger the onExtensionAfterSave event.
     $dispatcher->trigger('onExtensionAfterSave', array($name, &$table, false));
     return true;
 }