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 3c796e1

Browse filesBrowse files
committed
[Routing] Continue supporting single colon in object route loaders
1 parent ec781c9 commit 3c796e1
Copy full SHA for 3c796e1

File tree

Expand file treeCollapse file tree

3 files changed

+7
-26
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+7
-26
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Routing/Loader/ObjectLoader.php
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,15 @@ abstract protected function getObject(string $id);
4242
*/
4343
public function load($resource, $type = null)
4444
{
45-
if (!preg_match('/^[^\:]+(?:::(?:[^\:]+))?$/', $resource)) {
45+
if (!preg_match('/^[^\:]+(?:::?(?:[^\:]+))?$/', $resource)) {
4646
throw new \InvalidArgumentException(sprintf('Invalid resource "%s" passed to the %s route loader: use the format "object_id::method" or "object_id" if your object class has an "__invoke" method.', $resource, \is_string($type) ? '"'.$type.'"' : 'object'));
4747
}
4848

49+
if (1 === substr_count($resource, ':')) {
50+
$resource = str_replace(':', '::', $resource);
51+
@trigger_error(sprintf('Referencing object route loaders with a single colon is deprecated since Symfony 4.1. Use %s instead.', $resource), E_USER_DEPRECATED);
52+
}
53+
4954
$parts = explode('::', $resource);
5055
$method = $parts[1] ?? '__invoke';
5156

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Routing/Loader/ObjectRouteLoader.php
-24Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
namespace Symfony\Component\Routing\Loader;
1313

14-
use Symfony\Component\Routing\RouteCollection;
15-
1614
@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.4, use "%s" instead.', ObjectRouteLoader::class, ObjectLoader::class), E_USER_DEPRECATED);
1715

1816
/**
@@ -36,28 +34,6 @@ abstract class ObjectRouteLoader extends ObjectLoader
3634
*/
3735
abstract protected function getServiceObject($id);
3836

39-
/**
40-
* Calls the service that will load the routes.
41-
*
42-
* @param string $resource Some value that will resolve to a callable
43-
* @param string|null $type The resource type
44-
*
45-
* @return RouteCollection
46-
*/
47-
public function load($resource, $type = null)
48-
{
49-
if (!preg_match('/^[^\:]+(?:::?(?:[^\:]+))?$/', $resource)) {
50-
throw new \InvalidArgumentException(sprintf('Invalid resource "%s" passed to the "service" route loader: use the format "service::method" or "service" if your service has an "__invoke" method.', $resource));
51-
}
52-
53-
if (1 === substr_count($resource, ':')) {
54-
$resource = str_replace(':', '::', $resource);
55-
@trigger_error(sprintf('Referencing service route loaders with a single colon is deprecated since Symfony 4.1. Use %s instead.', $resource), E_USER_DEPRECATED);
56-
}
57-
58-
return parent::load($resource, $type);
59-
}
60-
6137
/**
6238
* {@inheritdoc}
6339
*/

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Routing/Tests/Loader/ObjectRouteLoaderTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
class ObjectRouteLoaderTest extends TestCase
2323
{
2424
/**
25-
* @expectedDeprecation Referencing service route loaders with a single colon is deprecated since Symfony 4.1. Use my_route_provider_service::loadRoutes instead.
25+
* @expectedDeprecation Referencing object route loaders with a single colon is deprecated since Symfony 4.1. Use my_route_provider_service::loadRoutes instead.
2626
*/
2727
public function testLoadCallsServiceAndReturnsCollectionWithLegacyNotation()
2828
{

0 commit comments

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