-
Notifications
You must be signed in to change notification settings - Fork 1
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
PoC Config objects #3
base: master
Are you sure you want to change the base?
Conversation
5c32860
to
6a5cb91
Compare
), | ||
'module_logpeek.php', | ||
'simplesaml' | ||
$this->moduleConfig = Config\Logpeek::fromArray( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can easily create a test-config from an array
@@ -133,8 +132,9 @@ public function testMainWithTag(): void | |||
['tag' => $this->session->getTrackID()] | |||
); | |||
|
|||
$c = new Controller\Logpeek($this->config, $this->session); | |||
$c = new Controller\Logpeek($this->config, $this->session, $this->moduleConfig); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is actually 'wrong';
We either have to pass the config through the constructor, or use the setter two lines below.
The setter is probably the way to go for now, until our module-system allows us to dynamically register services.. The config could then be passed as a service by the routing system, the same way we pass the configuration/session classes
* @param string $file | ||
* @return self | ||
*/ | ||
public static function fromPhp(string $configFile = 'module_logpeek.php'): self |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For BC compatibility
* @param string $file | ||
* @return self | ||
*/ | ||
public static function fromYaml(string $configFile = self::DEFAULT_CONFIGFILE): self |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is completely generic, so could be moved to an AbstractConfigObject
* @param array $config | ||
* @return self | ||
*/ | ||
public static function fromArray(array $config): self |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be implemented to assist unit testing
*/ | ||
protected function setLines(int $lines): void | ||
{ | ||
Assert::positiveInteger($lines); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can add many assertions to test the config values
*** NOT TO BE MERGED ***
This PR is a Proof of concept.