Skip to content
This repository has been archived by the owner on Jan 17, 2022. It is now read-only.

Commit

Permalink
fix(di): Do not use integer node for port
Browse files Browse the repository at this point in the history
When using environment variable for port in configuration, symfony command `bin/console debug:config swoole` was producing errors. Fixed deprecation warning regarding TreeBuilder.
  • Loading branch information
k911 committed Feb 28, 2019
1 parent 8744f30 commit ac6fdcf
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/Bridge/Symfony/Bundle/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@

final class Configuration implements ConfigurationInterface
{
private $builder;

public const DEFAULT_PUBLIC_DIR = '%kernel.project_dir%/public';

private const CONFIG_NAME = 'swoole';

private $builder;

public function __construct(TreeBuilder $builder)
{
$this->builder = $builder;
Expand All @@ -27,7 +29,9 @@ public function __construct(TreeBuilder $builder)
*/
public function getConfigTreeBuilder(): TreeBuilder
{
$rootNode = $this->builder->root('swoole');
$rootNode = \method_exists($this->builder, 'getRootNode') ?
$this->builder->getRootNode() :
$this->builder->root(self::CONFIG_NAME);

$rootNode
->children()
Expand All @@ -38,9 +42,8 @@ public function getConfigTreeBuilder(): TreeBuilder
->cannotBeEmpty()
->defaultValue('127.0.0.1')
->end()
->integerNode('port')
->min(0)
->max(65535)
->scalarNode('port')
->cannotBeEmpty()
->defaultValue(9501)
->end()
->arrayNode('trusted_hosts')
Expand Down Expand Up @@ -153,6 +156,6 @@ public function getConfigTreeBuilder(): TreeBuilder

public static function fromTreeBuilder(): self
{
return new self(new TreeBuilder());
return new self(new TreeBuilder(self::CONFIG_NAME));
}
}

0 comments on commit ac6fdcf

Please sign in to comment.