Skip to content

Commit

Permalink
SessionExtension: added values 'always' & 'never' for option 'autoStart'
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Nov 29, 2021
1 parent b926598 commit 8146c2f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Bridges/HttpDI/SessionExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function getConfigSchema(): Nette\Schema\Schema
{
return Expect::structure([
'debugger' => Expect::bool(false),
'autoStart' => Expect::anyOf('smart', true, false)->firstIsDefault(),
'autoStart' => Expect::anyOf('smart', 'always', 'never', true, false)->firstIsDefault(),
'expiration' => Expect::string()->dynamic(),
'handler' => Expect::string()->dynamic(),
'readAndClose' => Expect::bool(),
Expand Down Expand Up @@ -82,6 +82,9 @@ public function loadConfiguration()

$options = (array) $config;
unset($options['expiration'], $options['handler'], $options['autoStart'], $options['debugger']);
if ($config->autoStart === 'never') {
$options['autoStart'] = false;
}
if (!empty($options)) {
$session->addSetup('setOptions', [$options]);
}
Expand All @@ -96,7 +99,7 @@ public function loadConfiguration()
if ($config->autoStart === 'smart') {
$this->initialization->addBody('$this->getService(?)->autoStart(false);', [$name]);

} elseif ($config->autoStart) {
} elseif ($config->autoStart === 'always' || $config->autoStart === true) {
$this->initialization->addBody('$this->getService(?)->start();', [$name]);
}
}
Expand Down

0 comments on commit 8146c2f

Please sign in to comment.