Added Logging calls to \ncc\Managers > ConfigurationManager

This commit is contained in:
Netkas 2023-01-02 16:20:32 -05:00
parent 39d98f8ff3
commit 7c2735ce1b

View file

@ -5,7 +5,6 @@
namespace ncc\Managers; namespace ncc\Managers;
use Exception; use Exception;
use ncc\Abstracts\LogLevel;
use ncc\Abstracts\Scopes; use ncc\Abstracts\Scopes;
use ncc\Exceptions\AccessDeniedException; use ncc\Exceptions\AccessDeniedException;
use ncc\Exceptions\FileNotFoundException; use ncc\Exceptions\FileNotFoundException;
@ -50,6 +49,8 @@
*/ */
public function load(): void public function load(): void
{ {
Console::outDebug(sprintf('loading configuration file from %s', PathFinder::getConfigurationFile()));
$this->Configuration = RuntimeCache::get('ncc.yaml'); $this->Configuration = RuntimeCache::get('ncc.yaml');
if($this->Configuration !== null) if($this->Configuration !== null)
return; return;
@ -68,6 +69,8 @@
*/ */
public function save(): void public function save(): void
{ {
Console::outDebug(sprintf('saving configuration file to %s', PathFinder::getConfigurationFile()));
if(Resolver::resolveScope() !== Scopes::System) if(Resolver::resolveScope() !== Scopes::System)
throw new AccessDeniedException('Cannot save configuration file, insufficient permissions'); throw new AccessDeniedException('Cannot save configuration file, insufficient permissions');
@ -89,6 +92,8 @@
*/ */
public function getProperty(string $property) public function getProperty(string $property)
{ {
Console::outDebug(sprintf('getting property %s', $property));
Console::outDebug($property); Console::outDebug($property);
$current_selection = $this->getConfiguration(); $current_selection = $this->getConfiguration();
foreach(explode('.', strtolower($property)) as $property) foreach(explode('.', strtolower($property)) as $property)
@ -121,6 +126,8 @@
*/ */
public function updateProperty(string $property, $value): bool public function updateProperty(string $property, $value): bool
{ {
Console::outDebug(sprintf('updating property %s', $property));
$keys = explode('.', $property); $keys = explode('.', $property);
$current = &$this->Configuration; $current = &$this->Configuration;
foreach ($keys as $k) foreach ($keys as $k)