Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

[FrameworkBundle] Add support for first-class callable route controller in MicroKernelTrait#46009

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
nicolas-grekas merged 1 commit intosymfony:6.1fromfancyweb:fwb/kernel-fcc-route
Apr 12, 2022

Conversation

@fancyweb
Copy link
Contributor

@fancywebfancyweb commentedApr 12, 2022
edited
Loading

QA
Branch?6.1
Bug fix?no
New feature?yes
Deprecations?no
Tickets-
LicenseMIT
Doc PR-

I have some routes defined inKernel.php with the following syntax:

$routes->add('app_foo','/foo')    ->methods(['GET'])    ->controller([$this,'fooRoute']);

I'd like to switch them to:

$routes->add('app_foo','/foo')    ->methods(['GET'])    ->controller($this->fooRoute(...));

Because I'd like to use first-class callable syntax everywhere in the project.

michaljusiega and a-menshchikov reacted with thumbs up emoji

if (\is_array($controller) && [0,1] ===array_keys($controller) &&$this ===$controller[0]) {
$route->setDefault('_controller', ['kernel',$controller[1]]);
}elseif ($controllerinstanceof \Closure &&$this === ($r =new \ReflectionFunction($controller))->getClosureThis() && !str_contains($r->name,'{closure}')) {
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Anonymous functions and outside closures will continue to fail.

@nicolas-grekas
Copy link
Member

Thank you@fancyweb.

@nicolas-grekasnicolas-grekas merged commit7751cd3 intosymfony:6.1Apr 12, 2022
@fancywebfancyweb deleted the fwb/kernel-fcc-route branchApril 12, 2022 14:05
@fabpotfabpot mentioned this pull requestApr 15, 2022
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

6.1

Development

Successfully merging this pull request may close these issues.

3 participants

@fancyweb@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp