-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Deprecate bundle:controller:action and service:method notation #26085
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
Changes from all commits
110f18c
f6d6312
a296fd9
8b2069e
5701471
178270d
067a0d8
719f953
4f8e381
b5f10f8
26cad79
5221135
677e2ab
ea4dcdd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,14 +73,29 @@ public function load($resource, $type = null) | |
} | ||
|
||
foreach ($collection->all() as $route) { | ||
if (!is_string($controller = $route->getDefault('_controller')) || !$controller) { | ||
if (!is_string($controller = $route->getDefault('_controller'))) { | ||
continue; | ||
} | ||
|
||
try { | ||
$controller = $this->parser->parse($controller); | ||
} catch (\InvalidArgumentException $e) { | ||
// unable to optimize unknown notation | ||
if (false !== strpos($controller, '::')) { | ||
continue; | ||
} | ||
|
||
if (2 === substr_count($controller, ':')) { | ||
$deprecatedNotation = $controller; | ||
|
||
try { | ||
$controller = $this->parser->parse($controller, false); | ||
|
||
@trigger_error(sprintf('Referencing controllers with %s is deprecated since Symfony 4.1. Use %s instead.', $deprecatedNotation, $controller), E_USER_DEPRECATED); | ||
} catch (\InvalidArgumentException $e) { | ||
// unable to optimize unknown notation | ||
} | ||
} | ||
|
||
if (1 === substr_count($controller, ':')) { | ||
$controller = str_replace(':', '::', $controller); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unfortunately this change is a BC break and breaks custom code relying on single colon notation. (Simply commenting this out fixes the BC break.) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see. Removing this is an option. Do you want to create a PR? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Not necessarily, I don't have knowledge of Symfony test suite so I'd be happy if you do that, unless you are busy. 👍 Btw already reported in #27522. |
||
@trigger_error(sprintf('Referencing controllers with a single colon is deprecated since Symfony 4.1. Use %s instead.', $controller), E_USER_DEPRECATED); | ||
} | ||
|
||
$route->setDefault('_controller', $controller); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could use an
elseif
here if the condition is mutually exclusive with the one above. It would prevent evaluating this one when the first is true.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Depends if someone used an extended name parser that returned something else. I would leave it like this for simplicitly.