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

PoC Config objects #3

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

PoC Config objects #3

wants to merge 5 commits into from

Conversation

tvdijen
Copy link
Member

@tvdijen tvdijen commented Mar 10, 2022

*** NOT TO BE MERGED ***

This PR is a Proof of concept.

@tvdijen tvdijen force-pushed the poc_config branch 3 times, most recently from 5c32860 to 6a5cb91 Compare March 15, 2022 13:29
),
'module_logpeek.php',
'simplesaml'
$this->moduleConfig = Config\Logpeek::fromArray(
Copy link
Member Author

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);
Copy link
Member Author

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
Copy link
Member Author

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
Copy link
Member Author

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
Copy link
Member Author

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);
Copy link
Member Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant