mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-11 21:12:15 +09:00
Add AddonModel::getAddonConfig() method for easy access to addon config
This commit is contained in:
parent
27ccbc3d9e
commit
7e5defaeaf
3 changed files with 114 additions and 15 deletions
|
|
@ -141,6 +141,7 @@ class addonAdminController extends addonController
|
||||||
{
|
{
|
||||||
$this->makeCacheFile($site_srl, 'pc', 'site');
|
$this->makeCacheFile($site_srl, 'pc', 'site');
|
||||||
$this->makeCacheFile($site_srl, 'mobile', 'site');
|
$this->makeCacheFile($site_srl, 'mobile', 'site');
|
||||||
|
Rhymix\Framework\Cache::clearGroup('addonConfig');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->setMessage('success_updated', 'info');
|
$this->setMessage('success_updated', 'info');
|
||||||
|
|
@ -186,6 +187,7 @@ class addonAdminController extends addonController
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->makeCacheFile($site_module_info->site_srl, $type);
|
$this->makeCacheFile($site_module_info->site_srl, $type);
|
||||||
|
Rhymix\Framework\Cache::clearGroup('addonConfig');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -214,6 +216,9 @@ class addonAdminController extends addonController
|
||||||
|
|
||||||
$this->makeCacheFile($site_module_info->site_srl, "pc", 'site');
|
$this->makeCacheFile($site_module_info->site_srl, "pc", 'site');
|
||||||
$this->makeCacheFile($site_module_info->site_srl, "mobile", 'site');
|
$this->makeCacheFile($site_module_info->site_srl, "mobile", 'site');
|
||||||
|
Rhymix\Framework\Cache::delete(sprintf('addonConfig:%s:%s', $addon_name, 'any'));
|
||||||
|
Rhymix\Framework\Cache::delete(sprintf('addonConfig:%s:%s', $addon_name, 'pc'));
|
||||||
|
Rhymix\Framework\Cache::delete(sprintf('addonConfig:%s:%s', $addon_name, 'mobile'));
|
||||||
|
|
||||||
$this->setRedirectUrl(getNotEncodedUrl('', 'module', $module, 'act', 'dispAddonAdminSetup', 'selected_addon', $addon_name), $output);
|
$this->setRedirectUrl(getNotEncodedUrl('', 'module', $module, 'act', 'dispAddonAdminSetup', 'selected_addon', $addon_name), $output);
|
||||||
}
|
}
|
||||||
|
|
@ -234,11 +239,19 @@ class addonAdminController extends addonController
|
||||||
$args->is_used = $isUsed;
|
$args->is_used = $isUsed;
|
||||||
if($gtype == 'global')
|
if($gtype == 'global')
|
||||||
{
|
{
|
||||||
return executeQuery('addon.insertAddon', $args);
|
$output = executeQuery('addon.insertAddon', $args);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
$args->extra_vars = serialize($extra_vars);
|
$args->extra_vars = serialize($extra_vars);
|
||||||
$args->site_srl = $site_srl;
|
$args->site_srl = $site_srl;
|
||||||
return executeQuery('addon.insertSiteAddon', $args);
|
$output = executeQuery('addon.insertSiteAddon', $args);
|
||||||
|
}
|
||||||
|
|
||||||
|
Rhymix\Framework\Cache::delete(sprintf('addonConfig:%s:%s', $addon, 'any'));
|
||||||
|
Rhymix\Framework\Cache::delete(sprintf('addonConfig:%s:%s', $addon, 'pc'));
|
||||||
|
Rhymix\Framework\Cache::delete(sprintf('addonConfig:%s:%s', $addon, 'mobile'));
|
||||||
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -264,10 +277,18 @@ class addonAdminController extends addonController
|
||||||
}
|
}
|
||||||
if($gtype == 'global')
|
if($gtype == 'global')
|
||||||
{
|
{
|
||||||
return executeQuery('addon.updateAddon', $args);
|
$output = executeQuery('addon.updateAddon', $args);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
$args->site_srl = $site_srl;
|
$args->site_srl = $site_srl;
|
||||||
return executeQuery('addon.updateSiteAddon', $args);
|
$output = executeQuery('addon.updateSiteAddon', $args);
|
||||||
|
}
|
||||||
|
|
||||||
|
Rhymix\Framework\Cache::delete(sprintf('addonConfig:%s:%s', $addon, 'any'));
|
||||||
|
Rhymix\Framework\Cache::delete(sprintf('addonConfig:%s:%s', $addon, 'pc'));
|
||||||
|
Rhymix\Framework\Cache::delete(sprintf('addonConfig:%s:%s', $addon, 'mobile'));
|
||||||
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -292,10 +313,18 @@ class addonAdminController extends addonController
|
||||||
}
|
}
|
||||||
if($gtype == 'global')
|
if($gtype == 'global')
|
||||||
{
|
{
|
||||||
return executeQuery('addon.updateAddon', $args);
|
$output = executeQuery('addon.updateAddon', $args);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
$args->site_srl = $site_srl;
|
$args->site_srl = $site_srl;
|
||||||
return executeQuery('addon.updateSiteAddon', $args);
|
$output = executeQuery('addon.updateSiteAddon', $args);
|
||||||
|
}
|
||||||
|
|
||||||
|
Rhymix\Framework\Cache::delete(sprintf('addonConfig:%s:%s', $addon, 'any'));
|
||||||
|
Rhymix\Framework\Cache::delete(sprintf('addonConfig:%s:%s', $addon, 'pc'));
|
||||||
|
Rhymix\Framework\Cache::delete(sprintf('addonConfig:%s:%s', $addon, 'mobile'));
|
||||||
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -167,10 +167,18 @@ class addonController extends addon
|
||||||
$args->extra_vars = serialize($extra_vars);
|
$args->extra_vars = serialize($extra_vars);
|
||||||
if($gtype == 'global')
|
if($gtype == 'global')
|
||||||
{
|
{
|
||||||
return executeQuery('addon.updateAddon', $args);
|
$output = executeQuery('addon.updateAddon', $args);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
$args->site_srl = $site_srl;
|
$args->site_srl = $site_srl;
|
||||||
return executeQuery('addon.updateSiteAddon', $args);
|
$output = executeQuery('addon.updateSiteAddon', $args);
|
||||||
|
}
|
||||||
|
|
||||||
|
Rhymix\Framework\Cache::delete(sprintf('addonConfig:%s:%s', $addon, 'any'));
|
||||||
|
Rhymix\Framework\Cache::delete(sprintf('addonConfig:%s:%s', $addon, 'pc'));
|
||||||
|
Rhymix\Framework\Cache::delete(sprintf('addonConfig:%s:%s', $addon, 'mobile'));
|
||||||
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -184,6 +192,7 @@ class addonController extends addon
|
||||||
$args = new stdClass();
|
$args = new stdClass();
|
||||||
$args->site_srl = $site_srl;
|
$args->site_srl = $site_srl;
|
||||||
executeQuery('addon.deleteSiteAddons', $args);
|
executeQuery('addon.deleteSiteAddons', $args);
|
||||||
|
Rhymix\Framework\Cache::clearGroup('addonConfig');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
61
modules/addon/addon.model.php
Normal file
61
modules/addon/addon.model.php
Normal file
|
|
@ -0,0 +1,61 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class AddonModel extends Addon
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get configuration for addon
|
||||||
|
*
|
||||||
|
* @param string $addon_name
|
||||||
|
* @param string $type
|
||||||
|
* @return object|null
|
||||||
|
*/
|
||||||
|
public static function getAddonConfig(string $addon_name, string $type = 'any')
|
||||||
|
{
|
||||||
|
if (!in_array($type, ['any', 'pc', 'mobile']))
|
||||||
|
{
|
||||||
|
$type = 'any';
|
||||||
|
}
|
||||||
|
|
||||||
|
$cache_key = sprintf('addonConfig:%s:%s', $addon_name, $type);
|
||||||
|
$config = Rhymix\Framework\Cache::get($cache_key);
|
||||||
|
if ($config !== null)
|
||||||
|
{
|
||||||
|
return $config;
|
||||||
|
}
|
||||||
|
|
||||||
|
$args = new stdClass();
|
||||||
|
$args->addon = $addon_name;
|
||||||
|
$args->site_srl = 0;
|
||||||
|
$output = executeQueryArray('addon.getSiteAddonInfo', $args);
|
||||||
|
if (!$output->toBool() || !count($output->data))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = array_first($output->data);
|
||||||
|
if ($type === 'pc' && $result->is_used !== 'Y')
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if ($type === 'mobile' && $result->is_used_m !== 'Y')
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (!$result->extra_vars)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$config = unserialize($result->extra_vars);
|
||||||
|
unset($config->xe_validator_id);
|
||||||
|
if (!isset($config->mid_list))
|
||||||
|
{
|
||||||
|
$config->mid_list = [];
|
||||||
|
}
|
||||||
|
$config->use_pc = $result->is_used;
|
||||||
|
$config->use_mobile = $result->is_used_m;
|
||||||
|
|
||||||
|
Rhymix\Framework\Cache::set($cache_key, $config, 0, true);
|
||||||
|
return $config;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue