Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to reload config files #186

Merged
merged 1 commit into from
Jan 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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