Merge pull request #10700 from silverstripeltd/pulls/kernel-is-flushed

5-beta: Add isFlushed() to Kernel interface
This commit is contained in:
Guy Sartorelli 2023-02-23 11:27:06 +13:00 committed by GitHub
commit 981e20e298
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 20 deletions

View File

@ -188,7 +188,7 @@ abstract class BaseKernel implements Kernel
$this->getIncludeTests(), $this->getIncludeTests(),
$flush $flush
); );
// Flush config // Flush config
if ($flush) { if ($flush) {
$config = $this->getConfigLoader()->getManifest(); $config = $this->getConfigLoader()->getManifest();
@ -265,7 +265,7 @@ abstract class BaseKernel implements Kernel
abstract public function boot($flush = false); abstract public function boot($flush = false);
abstract public function isFlushed(); abstract public function isFlushed(): ?bool;
/** /**
* Check if there's a legacy _ss_environment.php file * Check if there's a legacy _ss_environment.php file

View File

@ -15,11 +15,8 @@ class CoreKernel extends BaseKernel
/** /**
* Indicates whether the Kernel has been flushed on boot * Indicates whether the Kernel has been flushed on boot
* Uninitialised before boot
*
* @var bool
*/ */
private $flush; private ?bool $flush = null;
/** /**
* @param false $flush * @param false $flush
@ -217,12 +214,7 @@ class CoreKernel extends BaseKernel
return null; return null;
} }
/** public function isFlushed(): ?bool
* Returns whether the Kernel has been flushed on boot
*
* @return bool|null null if the kernel hasn't been booted yet
*/
public function isFlushed()
{ {
return $this->flush; return $this->flush;
} }

View File

@ -16,11 +16,9 @@ class DatabaselessKernel extends BaseKernel
{ {
/** /**
* Indicates whether the Kernel has been flushed on boot * Indicates whether the Kernel has been flushed on boot
* Uninitialised before boot * Null before boot
*
* @var bool
*/ */
private $flush; private ?bool $flush = null;
/** /**
* Allows disabling of the configured error handling. * Allows disabling of the configured error handling.
@ -53,10 +51,7 @@ class DatabaselessKernel extends BaseKernel
$this->setBooted(true); $this->setBooted(true);
} }
/** public function isFlushed(): ?bool
* @return bool
*/
public function isFlushed()
{ {
return $this->flush; return $this->flush;
} }

View File

@ -132,4 +132,11 @@ interface Kernel
* @return $this * @return $this
*/ */
public function setEnvironment($environment); public function setEnvironment($environment);
/**
* Returns whether the Kernel has been flushed on boot
*
* @return bool|null null if the kernel hasn't been booted yet
*/
public function isFlushed(): ?bool;
} }