Skip to content

Commit

Permalink
Merge pull request #186 from j0k3r/reload-config-files
Browse files Browse the repository at this point in the history
Add ability to reload config files
  • Loading branch information
j0k3r authored Jan 4, 2019
2 parents b3dfd7b + 6e28b6a commit 5c9b33d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/Graby.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,16 @@ public function setLogger(LoggerInterface $logger)
$this->httpClient->setLogger($logger);
}

/**
* Reload configuration files.
*
* @see ConfigBuilder::loadConfigFiles
*/
public function reloadConfigFiles()
{
$this->configBuilder->loadConfigFiles();
}

/**
* Return a config.
*
Expand Down
14 changes: 13 additions & 1 deletion src/SiteConfig/ConfigBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,26 @@ public function __construct($config = [], LoggerInterface $logger = null)
$this->logger = new NullLogger();
}

$this->configFiles = Files::getFiles($this->config['site_config']);
$this->loadConfigFiles();
}

public function setLogger(LoggerInterface $logger)
{
$this->logger = $logger;
}

/**
* Load configuration files from filesystem.
* The load is externalized into a dedicated public method so we can reload config files after a custom creation of a config file.
* - Config files are loaded when the class is instancied.
* - If we add a new file after, it won't be loaded.
* - We'll need to manually reload config files.
*/
public function loadConfigFiles()
{
$this->configFiles = Files::getFiles($this->config['site_config']);
}

/**
* Add the given SiteConfig to the cache.
*
Expand Down

0 comments on commit 5c9b33d

Please sign in to comment.