Skip to content
Closed
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 @@ -260,7 +260,9 @@ public function addClassResource(\ReflectionClass $class)
}

do {
$this->addResource(new FileResource($class->getFileName()));
if (file_exists($class->getFileName())) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one can be applied to 2.3 but I'd like a review of this PR before

$this->addResource(new FileResource($class->getFileName()));
}
} while ($class = $class->getParentClass());

return $this;
Expand Down
4 changes: 3 additions & 1 deletion src/Symfony/Component/Routing/Loader/ObjectRouteLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ public function supports($resource, $type = null)
private function addClassResource(\ReflectionClass $class, RouteCollection $collection)
{
do {
$collection->addResource(new FileResource($class->getFileName()));
if (file_exists($class->getFileName())) {
$collection->addResource(new FileResource($class->getFileName()));
}
} while ($class = $class->getParentClass());
}
}
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function testLoadCallsServiceAndReturnsCollection()
$collection->add('foo', new Route('/foo'));

// create some callable object
$service = $this->getMockBuilder('stdClass')
$service = $this->getMockBuilder(__CLASS__)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stdClass has not parent class, let's take __CLASS__, which has

->setMethods(array('loadRoutes'))
->getMock();
$service->expects($this->once())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function testImport()
$originalRoute = new Route('/foo/path');
$expectedCollection = new RouteCollection();
$expectedCollection->add('one_test_route', $originalRoute);
$expectedCollection->addResource(new FileResource('file_resource.yml'));
$expectedCollection->addResource(new FileResource(__DIR__.'/Fixtures/foo.xml'));

$resolvedLoader
->expects($this->once())
Expand Down