Skip to content

Add posibility to specify method in router:match#9340

Closed
pmartelletti wants to merge 8 commits intosymfony:masterfrom
pmartelletti:master
Closed

Add posibility to specify method in router:match#9340
pmartelletti wants to merge 8 commits intosymfony:masterfrom
pmartelletti:master

Conversation

@pmartelletti
Copy link
Copy Markdown
Contributor

I think this was not possible, or I just was not able to find it anywhere, so I just implemented myself. Please feel free to ignore this PR if this was already possible from the command line, but please DO tell me how is it done. Thanks!

I think this was not possible, or I just was not able to find it anywhere, so I just implemented myself.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

without underscore

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

👍

@pmartelletti
Copy link
Copy Markdown
Contributor Author

Should I do a new PR with the suggested changes?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

without spaces insde ()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

please have a look at the symfony cs

@Tobion
Copy link
Copy Markdown
Contributor

Tobion commented Oct 18, 2013

@pmartelletti I like the PR. I also had this idea. You don't need a new PR. Updating this one is fine.

@stof
Copy link
Copy Markdown
Member

stof commented Oct 18, 2013

we would need host as well, as the routes can be aware of the host now

@pmartelletti
Copy link
Copy Markdown
Contributor Author

Do you want me to add 'host' as an optiona paramter too?

@pmartelletti
Copy link
Copy Markdown
Contributor Author

What do you think about it now? 😟

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

should be reverted

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

what do you mean by reverted? That it should not be marked as modified in the diff?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

you removed the ending comma

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

those 2 lines should be moved to the setDefinition call like done in other Symfony commands.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

In the AssetsInstallCommand options are set like this, that's why I opted to make it this way. 😟 Sorry about that.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

can you add a comma at the end of this one too?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

you could inject elegantly the assignments into the if expressions

if ($method = $input->getOption('method')) {

a la @fabpot

@cordoval
Copy link
Copy Markdown
Contributor

also add some command testing

@hacfi
Copy link
Copy Markdown
Contributor

hacfi commented Oct 28, 2013

Great addition..three days ago I was disappointed to find out that it wasn’t implemented yet!

@pmartelletti
Copy link
Copy Markdown
Contributor Author

@cordoval the actual command does not have any testing, or at least it's not under

FrameworkBundle/Tests/Command/

where I expected it should be. If tests are somewhere else, would be appreciated if you point me where so I don't duplicate testing. 😄

@wouterj
Copy link
Copy Markdown
Member

wouterj commented Nov 6, 2013

You're correct, there are no tests for this command. Could you please create them?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would remove the m shortcut here and use null instead like you did for the host.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Forces to match against the specified method -> Sets the HTTP method

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

VALUE_OPTIONAL should also be changed. It's not optional because just specifying --method doesn't make sense.
So instead it should be required and specify a default (GET) for it (fifth argument AFAIK).
The same also applies for host (localhost). These are the defaults of https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Routing/RequestContext.php#L53 as well.

Also it would be nice to add one more option: scheme (defaults to http).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think the default should be all methods, not only GET?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The default cannot be all method. The request context has only 1 method.

@fabpot
Copy link
Copy Markdown
Member

fabpot commented Dec 29, 2013

Can you add the PR header in your description? (see http://symfony.com/doc/current/contributing/code/patches.html#make-a-pull-request)?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

After applying the changes asked by @Tobion, you can safely remove the conditions and always set the values (as it would set the default value if the options are not passed explicitly).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I disagree here. The default values of the request context can be changed by changing the parameter. It would be weird if the command starts ignoring these overwritten defaults by always setting its own value

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

by changing the parameter

What parameter are you referring to?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If you mean a custom subclass with changed parameter defaults, then IMHO we should still set the values in the command to make it independent and work consistently. Otherwise the command would behave differently depending on what request context is used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants