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

Route action and controller parameter inconsistencies #13555

Closed
scrnjakovic opened this issue Oct 28, 2018 · 9 comments
Closed

Route action and controller parameter inconsistencies #13555

scrnjakovic opened this issue Oct 28, 2018 · 9 comments
Assignees
Labels
bug A bug report status: medium Medium
Milestone

Comments

@scrnjakovic
Copy link
Contributor

scrnjakovic commented Oct 28, 2018

$router->add('...', [
    'controller' => 'my_controller' // MyController
    'action' => 'my_action' // my_action
]);
@stamster
Copy link
Contributor

That's why I prefer to use MicroCollection - define everything manually.

$adminRoutes->get('/deconnexion', 'logout', 'admin_logout');

@scrnjakovic
Copy link
Contributor Author

@stamster nonetheless, the fact that framework treats those two differently is an issue :)

@Ark4ne
Copy link

Ark4ne commented Oct 30, 2018

Personally, I do not think it's a problem.

The controller is transformed because you have to use the PSR-4.
The action is not transformed because there is no standard for the use of camelCase or snakeCase.

It's up to the developer to do it right in my opinion.

@scrnjakovic
Copy link
Contributor Author

@Ark4ne the two are closely related, so if we use one case for controller, we should stick with it when it comes to the action as well, regardless of the lack of the standard for the action.

Standards exist so that code we write is compatible and predictable. The lack of it doesn't mean we should stop caring. Having controller and action use two completely different cases introduces unexpected behavior, especially since it's not clearly mentioned in the docs.

But I could delete my whole answer and just say consistency.

@niden niden self-assigned this Oct 31, 2018
@niden
Copy link
Sponsor Member

niden commented Oct 31, 2018

Not going to be fixed/addressed in 3.x series. Adding this to 4.x

Thank you @scrnjakovic

@niden niden added this to the 4.0.0 milestone Oct 31, 2018
@scrnjakovic
Copy link
Contributor Author

Nope, thank you @niden.

@JABirchall
Copy link

JABirchall commented Nov 11, 2018

@scrnjakovic If i get this right you want the framework to call your controller My_Controller
Unfortunatly I this will be possible, even in 4.x as 4.0 is aiming to be full PSR compliant, and class named My_Controller will violate:

you can't use underscores in Namespaces or classnames. They must be CamelCase with no seperations between words.

Also @Ark4ne PSR-1 4.3 enforces method naming conventions to lowerCamelCase.

The only bug is that the action does not get transformed to myAction @niden.

@gnumoksha
Copy link

@JABirchall as @scrnjakovic said, the problem is the different behaviour. my_controller will be mapped to MyController and my_action will be mapped to a controller's method named my_action. Since @Ark4ne already pointed out the PSR guidelines for the class name, the most reasonable is to change the way Phalcon maps the action name.

@niden
Copy link
Sponsor Member

niden commented Feb 6, 2019

Resolved

@niden niden closed this as completed Feb 6, 2019
@niden niden added the 4.0 label Jun 21, 2019
@niden niden added bug A bug report status: medium Medium and removed Bug - Medium labels Dec 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug report status: medium Medium
Projects
None yet
Development

No branches or pull requests

6 participants