Skip to content

Commit

Permalink
Rename useDevelopmentMode to enableDebugging
Browse files Browse the repository at this point in the history
The new name removes any relation between running environment and
debugging controls.

Signed-off-by: Luís Cobucci <[email protected]>
  • Loading branch information
lcobucci committed Nov 10, 2024
1 parent c36e18c commit 6aecee7
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
6 changes: 3 additions & 3 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ $testContainer = $builder->getTestContainer();
* `ContainerBuilder#addPass()`: Adds an instance of a [Compiler Pass](compiler-passes.md) to be processed
* `ContainerBuilder#addDelayedPass()`: Adds a reference (class name and constructor arguments) of a [Compiler Pass](compiler-passes.md) to be processed
* `ContainerBuilder#addPackage()`: Adds a reference (class name and constructor arguments) of a [Package](packages.md) to be processed
* `ContainerBuilder#useDevelopmentMode()`: Optimises the generate container for development purposes (configures the compiler to track file changes and update the cache)
* `ContainerBuilder#enableDebugging()`: Configures the compiler to track file changes and update the cache, optimised for local development purposes
* `ContainerBuilder#setDumpDir()`: Configures the directory to be used to dump the cache files
* `ContainerBuilder#setParameter()`: Configures a dynamic parameter
* `ContainerBuilder#setBaseClass()`: Modifies which class should be used as base class for the container
Expand All @@ -59,8 +59,8 @@ require __DIR__ . '/../vendor/autoload.php';
$builder = ContainerBuilder::xml(__FILE__, __NAMESPACE__);
$projectRoot = dirname(__DIR__);

if (getenv('APPLICATION_MODE', true) === 'development') {
$builder->useDevelopmentMode();
if (getenv('APP_PROFILE') !== 'prod') {
$builder->enableDebugging();
}

return $builder->setDumpDir($projectRoot . '/var/tmp')
Expand Down
9 changes: 9 additions & 0 deletions src/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,18 @@ public function addPackage(string $className, array $constructArguments = []): B

/**
* Mark the container to be used as development mode
*
* @deprecated this method will be removed in favour of a more explicit name.
*
* @see enableDebugging
*/
public function useDevelopmentMode(): Builder;

/**
* Configure the container to track file updates
*/
public function enableDebugging(): Builder;

/**
* Configures the dump directory
*/
Expand Down
5 changes: 5 additions & 0 deletions src/ContainerBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ public function addPackage(string $className, array $constructArguments = []): B
}

public function useDevelopmentMode(): Builder
{
return $this->enableDebugging();
}

public function enableDebugging(): Builder
{
$this->parameterBag->set('app.devmode', true);

Expand Down
4 changes: 2 additions & 2 deletions test/ContainerBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,11 @@ public function setBaseClassShouldConfigureTheBaseClassAndReturnSelf(): void
}

#[PHPUnit\Test]
public function useDevelopmentModeShouldChangeTheParameterAndReturnSelf(): void
public function enableDebuggingShouldChangeTheParameterAndReturnSelf(): void
{
$builder = new ContainerBuilder($this->config, $this->generator, $this->parameterBag);

self::assertSame($builder, $builder->useDevelopmentMode());
self::assertSame($builder, $builder->enableDebugging());
self::assertTrue($this->parameterBag->get('app.devmode'));
}

Expand Down

0 comments on commit 6aecee7

Please sign in to comment.