Skip to content

Commit

Permalink
Overall improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
LuckyCyborg committed Jul 1, 2019
1 parent 93d6214 commit c5a0a5f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 19 deletions.
7 changes: 4 additions & 3 deletions app/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@
//--------------------------------------------------------------------------

if (CONFIG_STORE === 'database') {

// Retrieve the Option items, caching them for 24 hours.
$options = Cache::remember('system_options', 1440, function ()
{
return Option::getResults();
return Option::all();
});

// Setup the information stored on the Option instances into Configuration.
foreach ($options as $option) {
list ($key, $value) = $option->getConfigItem();
$key = $option->getConfigKey();

Config::set($key, $value);
Config::set($key, $option->value);
}
}

Expand Down
26 changes: 11 additions & 15 deletions app/Models/Option.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,35 +33,31 @@ public function setValueAttribute($value)
$this->attributes['value'] = $this->maybeEncode($value);
}

public function getConfigItem()
public function getConfigKey()
{
if (! empty($namespace = $this->getAttribute('namespace'))) {
$key = $namespace .'::';
} else {
$key = '';
$namespace .= '::';
}

$key .= $this->getAttribute('group');
$key = $namespace .$this->getAttribute('group');

if (! empty($item = $this->getAttribute('item'))) {
$key .= '.' .$item;
return $key .'.' .$item;
}

return array($key, $this->getAttribute('value'));
return $key;
}

public static function getResults()
public static function all($columns = array('*'))
{
$instance = new static();

try {
return $instance->newQuery()->get();
return parent::all($columns);
}
catch (PDOException | QueryException $e) {
//
}

return $instance->newCollection();
return with(new static())->newCollection();
}

public static function set($key, $value)
Expand All @@ -75,11 +71,11 @@ public static function set($key, $value)

protected static function getItemResolver()
{
if (! isset(static::$itemResolver)) {
return static::$itemResolver = new NamespacedItemResolver();
if (isset(static::$itemResolver)) {
return static::$itemResolver;
}

return static::$itemResolver;
return static::$itemResolver = new NamespacedItemResolver();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/Platform/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// Define The Application Version
//--------------------------------------------------------------------------

define('VERSION', '4.1.12');
define('VERSION', '4.1.13');

//--------------------------------------------------------------------------
// Set PHP Error Reporting Options
Expand Down

0 comments on commit c5a0a5f

Please sign in to comment.