From 8146c2f2a262691a7139f9c56007961dcc5c1f42 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Sun, 5 Sep 2021 23:41:16 +0200 Subject: [PATCH] SessionExtension: added values 'always' & 'never' for option 'autoStart' --- src/Bridges/HttpDI/SessionExtension.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Bridges/HttpDI/SessionExtension.php b/src/Bridges/HttpDI/SessionExtension.php index ab7bd5ca..421e0d19 100644 --- a/src/Bridges/HttpDI/SessionExtension.php +++ b/src/Bridges/HttpDI/SessionExtension.php @@ -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(), @@ -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]); } @@ -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]); } }