| Current Path : /home/cbequiperp/www/plugins/system/installer_xtendr/ |
| Current File : /home/cbequiperp/www/plugins/system/installer_xtendr/installer_xtendr.php |
<?php
/**
* @package Smålabs Installer extender for Joomla
*
* @author Jasper Dik <joomla@smalabs.net>
* @link https://www.smalabs.net
* @copyright Copyright © 2017 J.J.A.Dik / Smålabs. All rights reserved.
* @license GNU/GPL version 3 (https://www.gnu.org/licenses/gpl-3.0.html)
*/
// No direct access
defined('_JEXEC') or die();
use Joomla\Registry\Registry;
use Smalabs\Joomla\Installer;
class plgSystemInstaller_xtendr extends JPlugin
{
/**
* Register the namespace of the Installer extender
*
* @since 1.0
*/
function onAfterInitialise()
{
\JLoader::registerNamespace('Smalabs\\Joomla\\Installer', JPATH_ROOT . '/plugins/system/installer_xtendr/libraries');
}
/**
* Function to trigger saving/updating the update key for on-site extension updates
*
* @param string $context
* @param JTable $table
* @param bool $isNew
*
* @return bool
*
* @since 1.0
*/
public function onExtensionBeforeSave($context, $table, $isNew)
{
switch ($context)
{
case 'com_config.component' :
case 'com_plugins.plugin' :
if ($isNew)
{
break;
}
$this->updateUpdateKey($table->params);
break;
case 'com_modules.module' :
$this->updateUpdateKey($table->params);
break;
case 'com_templates':
break;
}
return true;
}
/**
* Saves/Updates the update key for on-site updates to the database
*
* @param string $params JSON encoded version of the extension parameters
*
* @throws Exception
*
* @since 1.0
*/
protected function updateUpdateKey($params)
{
$params = new Registry($params);
$name = $params->get('sma_update_name', false);
$key = $params->get('sma_update_var', 'key');
$value = $params->get('sma_update_key', false);
if ($name && $key && $value)
{
Installer\System\Updater::setUpdateSite($name, $key, $value, true);
}
}
}