mirror of
https://github.com/DirectoryLister/DirectoryLister.git
synced 2025-08-18 11:51:40 +02:00
Container compilation configuration improvements
This commit is contained in:
@@ -14,7 +14,7 @@ class BootManager
|
||||
...glob($configPath . '/*.php')
|
||||
);
|
||||
|
||||
if (self::enableContainerCompilation()) {
|
||||
if (self::containerCompilationEnabled()) {
|
||||
$container->enableCompilation($cachePath);
|
||||
}
|
||||
|
||||
@@ -22,16 +22,18 @@ class BootManager
|
||||
}
|
||||
|
||||
/** Determine if container compilation should be enabled. */
|
||||
protected static function enableContainerCompilation(): bool
|
||||
protected static function containerCompilationEnabled(): bool
|
||||
{
|
||||
if (filter_var(getenv('APP_DEBUG'), FILTER_VALIDATE_BOOL)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (! filter_var(getenv('COMPILE_CONTAINER'), FILTER_VALIDATE_BOOL)) {
|
||||
return false;
|
||||
$compileContainer = getenv('COMPILE_CONTAINER');
|
||||
|
||||
if ($compileContainer === false) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
return strtolower($compileContainer) !== 'false';
|
||||
}
|
||||
}
|
||||
|
@@ -2,7 +2,6 @@
|
||||
|
||||
use App\Bootstrap\AppManager;
|
||||
use App\Bootstrap\BootManager;
|
||||
use DI\ContainerBuilder;
|
||||
use Dotenv\Dotenv;
|
||||
|
||||
require __DIR__ . '/app/vendor/autoload.php';
|
||||
|
@@ -22,10 +22,9 @@ class BootManagerTest extends TestCase
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_caches_the_container_when_compile_container_is_true(): void
|
||||
public function it_caches_the_container_by_default(): void
|
||||
{
|
||||
putenv('APP_DEBUG=false');
|
||||
putenv('COMPILE_CONTAINER=true');
|
||||
putenv('COMPILE_CONTAINER=');
|
||||
|
||||
$container = BootManager::createContainer(
|
||||
$this->filePath('app/config'),
|
||||
@@ -37,9 +36,8 @@ class BootManagerTest extends TestCase
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_does_not_cache_the_container_when_compilation_is_explicitly_disabled(): void
|
||||
public function it_does_not_cache_the_container_when_explicitly_disabled(): void
|
||||
{
|
||||
putenv('APP_DEBUG=false');
|
||||
putenv('COMPILE_CONTAINER=false');
|
||||
|
||||
$container = BootManager::createContainer(
|
||||
@@ -55,7 +53,6 @@ class BootManagerTest extends TestCase
|
||||
public function it_does_not_cache_the_container_when_debug_is_enabled(): void
|
||||
{
|
||||
putenv('APP_DEBUG=true');
|
||||
putenv('COMPILE_CONTAINER=true');
|
||||
|
||||
$container = BootManager::createContainer(
|
||||
$this->filePath('app/config'),
|
||||
|
Reference in New Issue
Block a user