Joomla-cms: [4.0] Namespace 'format' controller

Created on 2 Apr 2017  路  8Comments  路  Source: joomla/joomla-cms

Our legacy MVC allows creating separate controller class for each format (raw, json...) like in this class https://github.com/joomla/joomla-cms/blob/staging/components/com_users/controllers/profile.json.php

We need to decide how we want handle it in in namespace MVC for Joomla 4.. Some possible class names:

  • JoomlaComponentContentSiteController\Json\Profile
  • JoomlaComponentContentSiteController\JsonProfile
  • JoomlaComponentContentSiteController\ProfileJson

Once decision image, we will need to implement the change in component dispatcher to support this naming convention

No Code Attached Yet

Most helpful comment

What is the need for separate controller classes based on the request format? The only classes that should have an architectural need for variants based on request format should be views.

All 8 comments

What is the need for separate controller classes based on the request format? The only classes that should have an architectural need for variants based on request format should be views.

I don't really know as I haven't checked the code carefully yet. Saw it in legacy MVC and in the code of com_users as the link I posted above

I know the code is doing it now, what I'm basically asking is why do we need to carry that behavior forward? Is this a behavior we can deprecate?

To have the answer, I will have to look at the current code/ function to see whether we need it in namespace controller. As I said, I haven't looked at that part of code carefully yet. Will update here once I looked at it and understand the purpose of the current code

While you are here, could you please take a look at the other question https://github.com/joomla/joomla-cms/issues/15041 ?

@joomdonation is this still an open issue. The last comment suggests you were going to come back with an answer to @mbabker question

Sorry, I forgot to close this one. Closing it now.

I agree with @mbabker here. Supporting this behaviour encourages people to do something like this: https://groups.google.com/d/msg/joomla-dev-cms/WsC0nA9Fixo/Ur-gPqpqh-EJ. This is also referenced in com_ajax as the best way for JSON output.

Though they can do the same with a normal controller class but at least we should not encourage this. The output should be the job of views not controllers.

Though I should not be commenting on a closed issue, this is what I needed to add. May be we should start a new thread?

Was this page helpful?
0 / 5 - 0 ratings