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

[2.2][Routing] Added support for default attributes with default values of method params#5904

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

Closed

Conversation

@lyrixx
Copy link
Member

Bug fix: no
Feature addition: yes
Backwards compatibility break: no
Symfony2 tests pass: yes

With this patch, you can configure your default values likes this:

/** * @Route("/hi/{name}", name="hi") */publicfunctionhiAction($name ="Bob"){returnnewResponse($name);}

@Tobion
Copy link
Contributor

I'm unsure. How does one know if that param defines a default value or a requirement? It's too vague.

@lyrixx
Copy link
MemberAuthor

It's only a default value, not a requirement.
It's just a shortcut to avoiddefaults={"name"="bob"}

@Tobion
Copy link
Contributor

Yes, but its not clear. It could also be a shortcut torequirements={"name"="bob"}, which has totally different meaning. So it's not self-explanatory.
-1 for me.

@lyrixx
Copy link
MemberAuthor

it is the default php behavior. It's a default value for a variable...

@stof
Copy link
Member

stof commentedNov 4, 2012

@Tobion using the default value of the method to set a requirement does not make any sense. I don't see why someone would expect this behavior

@fabpot
Copy link
Member

@lyrixx Can you add some unit tests?

@Tobion
Copy link
Contributor

Oh I misunderstood the PR. I thought this makes thename param default tohi.@Route("/hi/{name}", name="hi"). But it's just the name of the route. Your example was easy to misinterpret as you usedname everywhere.

Copy link
Contributor

Choose a reason for hiding this comment

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

getDefaultValue()

@fabpot
Copy link
Member

@lyrixx Can you finish this PR?

@lyrixx
Copy link
MemberAuthor

@fabpot Yes i will as soon as possible.

@lyrixx
Copy link
MemberAuthor

I rebase and amend my commit. (I changed doc in commit message to be less confusing)

I will try to add tests.
But for now,AnnotationClassLoader::load is not really tested, andAnnotationClassLoader::addRoute is absolutely not tested. So I think I should add tests for these methods ? And then add tests for my patch.
I will try tomorrow.

… method paramsYou can configure default values likes this:``` php/** *@route("/hi/{username}", name="hi") */public function hiAction($username = "Bob"){    return new Response($username);}```
@lyrixx
Copy link
MemberAuthor

@fabpot I added new tests. I tried to made very atomic commits.

@TobionTobion mentioned this pull requestApr 20, 2013
lyrixx pushed a commit to lyrixx/SensioFrameworkExtraBundle that referenced this pull requestJan 10, 2014
This PR was merged into the master branch.Commits-------79d7839 [Doc] Added more doc about default value06e22ab [Doc] Be more consistant on routing exampleDiscussion----------Doc command default valueseesymfony/symfony#5904
henrikbjorn pushed a commit to henrikbjorn/ParamConverter that referenced this pull requestOct 14, 2014
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@lyrixx@Tobion@stof@fabpot

[8]ページ先頭

©2009-2025 Movatter.jp