forked from projects/fipamo
ro
0951005341
it's time to get the setting api running so site options can be editied so the first step is to get the settings page up and running. the sorting class is getting a bit heavy, but it will hold the method for gathering settings page info for now.
71 lines
1.6 KiB
PHP
71 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Services;
|
|
|
|
class SettingsService
|
|
{
|
|
protected $settings;
|
|
protected $folks;
|
|
protected $tags;
|
|
protected $docs;
|
|
|
|
public function __construct(DocService $docService)
|
|
{
|
|
$this->folks = json_decode(file_get_contents(env('FOLKS_PATH')), true);
|
|
$this->tags = json_decode(file_get_contents(env('TAGS_PATH')), true);
|
|
$this->docs = $docService;
|
|
}
|
|
|
|
protected function loadSettings()
|
|
{
|
|
return json_decode(file_get_contents(env('SETTINGS_PATH')), true);
|
|
}
|
|
|
|
public function getSettings()
|
|
{
|
|
return $this->loadSettings();
|
|
}
|
|
|
|
public function getGlobal()
|
|
{
|
|
$this->settings = $this->loadSettings();
|
|
return $this->settings['global'];
|
|
}
|
|
|
|
public function getEmail()
|
|
{
|
|
$this->settings = $this->loadSettings();
|
|
return $this->settings['email'];
|
|
}
|
|
|
|
public function getMenu()
|
|
{
|
|
$this->settings = $this->loadSettings();
|
|
return $this->settings['menu'];
|
|
}
|
|
|
|
public function getTags()
|
|
{
|
|
return $this->tags;
|
|
}
|
|
|
|
public function getFolks()
|
|
{
|
|
return $this->folks;
|
|
}
|
|
|
|
public function updatePageIndex()
|
|
{
|
|
$this->settings = $this->loadSettings();
|
|
$this->settings['library_stats']['current_index']++;
|
|
$this->docs->writeSettings($this->settings);
|
|
}
|
|
|
|
public function updateGlobalData($key, $value)
|
|
{
|
|
$this->settings = $this->loadSettings();
|
|
$this->settings['global'][$key] = $data;
|
|
$this->docs->writeSettings($this->settings);
|
|
}
|
|
}
|