Update ClientSettings.php and WebsiteSettings.php
~ Add extra checks to Alphaland\Client\ClientSettingsApplications::FetchCombinedApplicationDependencies() to:
1. Determine if the application dependency actually exists
2. Determine if the application dependency has a dependency to it's
super dependant
~ Make the Alphaland\Client\ClientSettingsKind an abstract class
~ Add Alphaland\Web\WebsiteSettings::GetOrCreateSetting() to website
settings in case we want to write a setting if it truly doesn't exist
Co-Authored-by: Jacob Valara <valara2@mfdlabs.com>
This commit is contained in:
parent
c040db0c1f
commit
678a5e6e8a
|
|
@ -409,6 +409,16 @@ namespace Alphaland\Client {
|
||||||
$combinedDependencies = self::GetApplicationSettings($applicationName);
|
$combinedDependencies = self::GetApplicationSettings($applicationName);
|
||||||
|
|
||||||
foreach ($currentDependencies as $dependency) {
|
foreach ($currentDependencies as $dependency) {
|
||||||
|
// skip it if it doesn't exist just to be safe
|
||||||
|
if (!self::ApplicationExists($dependency)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if the dependency has a dep on us already
|
||||||
|
if (self::ApplicationHasDependency($dependency, $applicationName)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if ($recursive && self::ApplicationHasAnyDependencies($dependency)) {
|
if ($recursive && self::ApplicationHasAnyDependencies($dependency)) {
|
||||||
$combinedDependencies = array_merge($combinedDependencies, self::FetchCombinedApplicationDependencies($dependency, $recursive));
|
$combinedDependencies = array_merge($combinedDependencies, self::FetchCombinedApplicationDependencies($dependency, $recursive));
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -464,7 +474,7 @@ namespace Alphaland\Client {
|
||||||
/**
|
/**
|
||||||
* The client settings kind.
|
* The client settings kind.
|
||||||
*/
|
*/
|
||||||
class ClientSettingsKind
|
abstract class ClientSettingsKind
|
||||||
{
|
{
|
||||||
public const Unscoped = "Unscoped";
|
public const Unscoped = "Unscoped";
|
||||||
public const FastLog = "FastLog";
|
public const FastLog = "FastLog";
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ namespace Alphaland\Web {
|
||||||
|
|
||||||
use PDO;
|
use PDO;
|
||||||
|
|
||||||
class WebsiteSettings
|
/* public static */ class WebsiteSettings
|
||||||
{
|
{
|
||||||
// default return if no settings are found
|
// default return if no settings are found
|
||||||
// because there may be a NULL value in the database
|
// because there may be a NULL value in the database
|
||||||
|
|
@ -99,6 +99,24 @@ namespace Alphaland\Web {
|
||||||
return self::ConvertStringToValue($result['value'], $result['type']);
|
return self::ConvertStringToValue($result['value'], $result['type']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets or sets the value of a website setting.
|
||||||
|
*
|
||||||
|
* @param string $name The name of the setting.
|
||||||
|
* @param mixed $value The value of the setting.
|
||||||
|
* @param string $type The type of the setting.
|
||||||
|
*
|
||||||
|
* @return mixed The value of the setting.
|
||||||
|
*/
|
||||||
|
public static function GetOrCreateSetting(string $name, $value = null, string $type = null)
|
||||||
|
{
|
||||||
|
if (!self::SettingExists($name)) {
|
||||||
|
self::UpdateSetting($name, $value, $type);
|
||||||
|
}
|
||||||
|
|
||||||
|
return self::GetSetting($name);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a website setting.
|
* Sets a website setting.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue