Initial config file parsing logic
This commit is contained in:
@ -2,6 +2,8 @@
|
||||
|
||||
namespace NoccyLabs\Mercureact;
|
||||
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
class Configuration
|
||||
{
|
||||
private ?string $publicUrl = null;
|
||||
@ -15,6 +17,27 @@ class Configuration
|
||||
return new Configuration();
|
||||
}
|
||||
|
||||
public static function fromFile(string $file): Configuration
|
||||
{
|
||||
$config = new Configuration();
|
||||
|
||||
$yaml = Yaml::parseFile($file);
|
||||
|
||||
if (isset($yaml['security'])) {
|
||||
$security = $yaml['security'];
|
||||
if (isset($security['jwt_secret']))
|
||||
$config->setJwtSecret($security['jwt_secret']);
|
||||
}
|
||||
|
||||
if (isset($yaml['subscribe'])) {
|
||||
$subscribe = $yaml['subscribe'];
|
||||
if (isset($subscribe['allow_anonymous']))
|
||||
$config->setAllowAnonymousSubscribe(boolval($subscribe['allow_anonymous']));
|
||||
}
|
||||
|
||||
return $config;
|
||||
}
|
||||
|
||||
public function setPublicUrl(string $publicUrl): self
|
||||
{
|
||||
$this->publicUrl = $publicUrl;
|
||||
|
Reference in New Issue
Block a user