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 0114091

Browse filesBrowse files
bug #17673 [Routing] add files used in FileResource objects (xabbuh)
This PR was merged into the 2.8 branch. Discussion ---------- [Routing] add files used in FileResource objects | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #17598 (comment) | License | MIT | Doc PR | Starting with Symfony 3.1, the constructor of the `FileResource` class will throw an exception when the passed file does not exist. Commits ------- 73afd0f add files used in FileResource objects
2 parents 85cad75 + 73afd0f commit 0114091
Copy full SHA for 0114091

File tree

4 files changed

+20
-12
lines changed
Filter options

4 files changed

+20
-12
lines changed

‎src/Symfony/Component/Routing/Loader/ObjectRouteLoader.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Routing/Loader/ObjectRouteLoader.php
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ public function supports($resource, $type = null)
8787
private function addClassResource(\ReflectionClass $class, RouteCollection $collection)
8888
{
8989
do {
90-
$collection->addResource(new FileResource($class->getFileName()));
90+
if (is_file($class->getFileName())) {
91+
$collection->addResource(new FileResource($class->getFileName()));
92+
}
9193
} while ($class = $class->getParentClass());
9294
}
9395
}

‎src/Symfony/Component/Routing/Tests/Fixtures/file_resource.yml

Copy file name to clipboardExpand all lines: src/Symfony/Component/Routing/Tests/Fixtures/file_resource.yml
Whitespace-only changes.

‎src/Symfony/Component/Routing/Tests/Loader/ObjectRouteLoaderTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Routing/Tests/Loader/ObjectRouteLoaderTest.php
+16-10Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,8 @@ public function testLoadCallsServiceAndReturnsCollection()
2525
$collection = new RouteCollection();
2626
$collection->add('foo', new Route('/foo'));
2727

28-
// create some callable object
29-
$service = $this->getMockBuilder('stdClass')
30-
->setMethods(array('loadRoutes'))
31-
->getMock();
32-
$service->expects($this->once())
33-
->method('loadRoutes')
34-
->with($loader)
35-
->will($this->returnValue($collection));
36-
3728
$loader->loaderMap = array(
38-
'my_route_provider_service' => $service,
29+
'my_route_provider_service' => new RouteService($collection),
3930
);
4031

4132
$actualRoutes = $loader->load(
@@ -114,3 +105,18 @@ protected function getServiceObject($id)
114105
return isset($this->loaderMap[$id]) ? $this->loaderMap[$id] : null;
115106
}
116107
}
108+
109+
class RouteService
110+
{
111+
private $collection;
112+
113+
public function __construct($collection)
114+
{
115+
$this->collection = $collection;
116+
}
117+
118+
public function loadRoutes()
119+
{
120+
return $this->collection;
121+
}
122+
}

‎src/Symfony/Component/Routing/Tests/RouteCollectionBuilderTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Routing/Tests/RouteCollectionBuilderTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function testImport()
3030
$originalRoute = new Route('/foo/path');
3131
$expectedCollection = new RouteCollection();
3232
$expectedCollection->add('one_test_route', $originalRoute);
33-
$expectedCollection->addResource(new FileResource('file_resource.yml'));
33+
$expectedCollection->addResource(new FileResource(__DIR__.'/Fixtures/file_resource.yml'));
3434

3535
$resolvedLoader
3636
->expects($this->once())

0 commit comments

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