Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[DI][Routing] add wither to configure the path of PHP-DSL configurators #35514

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ public function registerContainerConfiguration(LoaderInterface $loader)
}

// the user has opted into using the ContainerConfigurator
$defaultDefinition = (new Definition())->setAutowired(true)->setAutoconfigured(true);
/* @var ContainerPhpFileLoader $kernelLoader */
$kernelLoader = $loader->getResolver()->resolve($file);
$kernelLoader->setCurrentDir(\dirname($file));
Expand All @@ -136,7 +135,7 @@ public function registerContainerConfiguration(LoaderInterface $loader)
};

try {
$this->configureContainer(new ContainerConfigurator($container, $kernelLoader, $instanceof, $file, $file, $defaultDefinition), $loader);
$this->configureContainer(new ContainerConfigurator($container, $kernelLoader, $instanceof, $file, $file), $loader);
} finally {
$instanceof = [];
$kernelLoader->registerAliasesForSinglyImplementedInterfaces();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ protected function configureContainer(ContainerConfigurator $c)
$c->services()
->set('logger', NullLogger::class)
->set('stdClass', 'stdClass')
->autowire()
->factory([$this, 'createHalloween'])
->arg('$halloween', '%halloween%');

Expand Down
2 changes: 1 addition & 1 deletion 2 src/Symfony/Bundle/FrameworkBundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"symfony/polyfill-mbstring": "~1.0",
"symfony/filesystem": "^4.4|^5.0",
"symfony/finder": "^4.4|^5.0",
"symfony/routing": "^5.0"
"symfony/routing": "^5.1"
},
"require-dev": {
"doctrine/annotations": "~1.7",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,14 @@ class ContainerConfigurator extends AbstractConfigurator
private $path;
private $file;
private $anonymousCount = 0;
private $defaultDefinition;

public function __construct(ContainerBuilder $container, PhpFileLoader $loader, array &$instanceof, string $path, string $file, Definition $defaultDefinition = null)
public function __construct(ContainerBuilder $container, PhpFileLoader $loader, array &$instanceof, string $path, string $file)
{
$this->container = $container;
$this->loader = $loader;
$this->instanceof = &$instanceof;
$this->path = $path;
$this->file = $file;
$this->defaultDefinition = $defaultDefinition;
}

final public function extension(string $namespace, array $config)
Expand All @@ -69,7 +67,18 @@ final public function parameters(): ParametersConfigurator

final public function services(): ServicesConfigurator
{
return new ServicesConfigurator($this->container, $this->loader, $this->instanceof, $this->path, $this->anonymousCount, $this->defaultDefinition);
return new ServicesConfigurator($this->container, $this->loader, $this->instanceof, $this->path, $this->anonymousCount);
}

/**
* @return static
*/
final public function withPath(string $path): self
{
$clone = clone $this;
$clone->path = $clone->file = $path;

return $clone;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,16 @@ class ServicesConfigurator extends AbstractConfigurator
private $path;
private $anonymousHash;
private $anonymousCount;
private $defaultDefinition;

public function __construct(ContainerBuilder $container, PhpFileLoader $loader, array &$instanceof, string $path = null, int &$anonymousCount = 0, Definition $defaultDefinition = null)
public function __construct(ContainerBuilder $container, PhpFileLoader $loader, array &$instanceof, string $path = null, int &$anonymousCount = 0)
{
$defaultDefinition = $defaultDefinition ?? new Definition();
$this->defaults = clone $defaultDefinition;
$this->defaults = new Definition();
$this->container = $container;
$this->loader = $loader;
$this->instanceof = &$instanceof;
$this->path = $path;
$this->anonymousHash = ContainerBuilder::hash($path ?: mt_rand());
$this->anonymousCount = &$anonymousCount;
$this->defaultDefinition = $defaultDefinition;
$instanceof = [];
}

Expand All @@ -53,7 +50,7 @@ public function __construct(ContainerBuilder $container, PhpFileLoader $loader,
*/
final public function defaults(): DefaultsConfigurator
{
return new DefaultsConfigurator($this, $this->defaults = clone $this->defaultDefinition, $this->path);
return new DefaultsConfigurator($this, $this->defaults = new Definition(), $this->path);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,15 @@ final public function collection(string $name = ''): CollectionConfigurator
{
return new CollectionConfigurator($this->collection, $name);
}

/**
* @return static
*/
final public function withPath(string $path): self
{
$clone = clone $this;
$clone->path = $clone->file = $path;

return $clone;
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.