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

Commit 239f2e2

Browse filesBrowse files
[Routing] Fix GC control of PHP-DSL
1 parent 84fd602 commit 239f2e2
Copy full SHA for 239f2e2

File tree

4 files changed

+12
-5
lines changed
Filter options

4 files changed

+12
-5
lines changed

‎src/Symfony/Component/Routing/Loader/Configurator/CollectionConfigurator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Routing/Loader/Configurator/CollectionConfigurator.php
+5-3Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,15 @@ class CollectionConfigurator
2323
use Traits\RouteTrait;
2424

2525
private $parent;
26+
private $parentConfigurator;
2627

27-
public function __construct(RouteCollection $parent, $name)
28+
public function __construct(RouteCollection $parent, $name, self $parentConfigurator = null)
2829
{
2930
$this->parent = $parent;
3031
$this->name = $name;
3132
$this->collection = new RouteCollection();
3233
$this->route = new Route('');
34+
$this->parentConfigurator = $parentConfigurator; // for GC control
3335
}
3436

3537
public function __destruct()
@@ -50,7 +52,7 @@ final public function add($name, $path)
5052
{
5153
$this->collection->add($this->name.$name, $route = clone $this->route);
5254

53-
return new RouteConfigurator($this->collection, $route->setPath($path), $this->name);
55+
return new RouteConfigurator($this->collection, $route->setPath($path), $this->name, $this);
5456
}
5557

5658
/**
@@ -60,7 +62,7 @@ final public function add($name, $path)
6062
*/
6163
final public function collection($name = '')
6264
{
63-
return new self($this->collection, $this->name.$name);
65+
return new self($this->collection, $this->name.$name, $this);
6466
}
6567

6668
/**

‎src/Symfony/Component/Routing/Loader/Configurator/RouteConfigurator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Routing/Loader/Configurator/RouteConfigurator.php
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,13 @@ class RouteConfigurator
2222
use Traits\AddTrait;
2323
use Traits\RouteTrait;
2424

25-
public function __construct(RouteCollection $collection, Route $route, $name = '')
25+
private $parentConfigurator;
26+
27+
public function __construct(RouteCollection $collection, Route $route, $name = '', CollectionConfigurator $parentConfigurator = null)
2628
{
2729
$this->collection = $collection;
2830
$this->route = $route;
2931
$this->name = $name;
32+
$this->parentConfigurator = $parentConfigurator; // for GC control
3033
}
3134
}

‎src/Symfony/Component/Routing/Loader/Configurator/Traits/AddTrait.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Routing/Loader/Configurator/Traits/AddTrait.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ trait AddTrait
3434
*/
3535
final public function add($name, $path)
3636
{
37+
$parentConfigurator = $this instanceof RouteConfigurator ? $this->parentConfigurator : null;
3738
$this->collection->add($this->name.$name, $route = new Route($path));
3839

39-
return new RouteConfigurator($this->collection, $route);
40+
return new RouteConfigurator($this->collection, $route, $parentConfigurator);
4041
}
4142

4243
/**

‎src/Symfony/Component/Routing/Tests/Fixtures/php_dsl.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Routing/Tests/Fixtures/php_dsl.php
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
return function (RoutingConfigurator $routes) {
66
$routes
7+
->collection()
78
->add('foo', '/foo')
89
->condition('abc')
910
->options(array('utf8' => true))

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.