Skip to content
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

[5.5] Add option to get an route action by key #20975

Merged
merged 2 commits into from
Sep 5, 2017
Merged

[5.5] Add option to get an route action by key #20975

merged 2 commits into from
Sep 5, 2017

Conversation

ThorbenG
Copy link
Contributor

@ThorbenG ThorbenG commented Sep 4, 2017

With this PR its easier to get an specific route action.

Before you had to use the getAction() method to get the action array from a route and than use the key to get an action like this:
$route->getAction()['controller'];

Now you can get the action directly by using:
$route->getAction('controller');

Without an valid action key the method returns the action array.

@ThorbenG ThorbenG changed the title Add option to get an route action by key [5.5] Add option to get an route action by key Sep 4, 2017
@taylorotwell taylorotwell merged commit 213312a into laravel:5.5 Sep 5, 2017
@kamui545
Copy link
Contributor

kamui545 commented Sep 7, 2017

Pretty cool. However, am I the only one bothered by the fact that it is returning the action array if the key is not found?

Wouldn't it be more appropriate to return null instead as we expect a very specific property?

I find this misleading, especially if using it in a condition.
Eg: if ($route->getAction('controller')), even if there is no controllers it will return true...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants