Feature Request - Enhancement of Depreciated controllers #405

Closed
opened 2019-04-10 22:15:55 +00:00 by mwweb · 5 comments
mwweb commented 2019-04-10 22:15:55 +00:00 (Migrated from github.com)

I just found in looking through some of the things for the joomla api that some of the controllers being utilized in JCB are depreciated, which means they will be disappearing sooner or later.

One example:
class Hello_worldControllerGreeting extends JControllerForm

JControllerForm is Depreciated, with the recommendation to use the Default MVC Library https://api.joomla.org/cms-3/classes/JControllerBase.html

What might be good when updating/modifying is to add more flexibility. For example, the MVC Library offers 3 different classes for Controller: AdminController, BaseController, and FormController. Perhaps have options one site views to select which controller class, or model class, or even view class that should be used.

So, if I wanted to use BaseController, I could select it, and JCB would insert something similar to this:

require_once JPATH_COMPONENT.'/controller.php';

use Joomla\CMS\MVC\Controller\BaseController;

class Hello_worldControllerGreeting extends BaseController

https://api.joomla.org/cms-3/namespaces/Joomla.CMS.MVC.html

Currently I have been overwriting JCB code with custom code to update these.

I just found in looking through some of the things for the joomla api that some of the controllers being utilized in JCB are depreciated, which means they will be disappearing sooner or later. One example: class Hello_worldControllerGreeting extends JControllerForm JControllerForm is Depreciated, with the recommendation to use the Default MVC Library [https://api.joomla.org/cms-3/classes/JControllerBase.html](url) What might be good when updating/modifying is to add more flexibility. For example, the MVC Library offers 3 different classes for Controller: AdminController, BaseController, and FormController. Perhaps have options one site views to select which controller class, or model class, or even view class that should be used. So, if I wanted to use BaseController, I could select it, and JCB would insert something similar to this: require_once JPATH_COMPONENT.'/controller.php'; use Joomla\CMS\MVC\Controller\BaseController; class Hello_worldControllerGreeting extends BaseController [https://api.joomla.org/cms-3/namespaces/Joomla.CMS.MVC.html](url) Currently I have been overwriting JCB code with custom code to update these.

Are you willing to share what you have over written per/file?

Are you willing to share what you have over written per/file?
mwweb commented 2019-04-13 22:11:43 +00:00 (Migrated from github.com)

Absolutely. These examples are for site controllers and views, but it should be similar for admin.

*** For controller, JCB currently uses:

class DemoControllerLook extends JControllerForm

Change it to :

use Joomla\CMS\MVC\Controller\BaseController;

class DemoControllerLook extends BaseController

*** For models, JCB currently uses:

class DemoModelLooks extends JModelList

change to

use Joomla\CMS\MVC\Model\ListModel;

class DemoModelCategory extends ListModel

Attached is a list of what the "old" class is, and what the new class is. Joomla currently has them setup as aliases. So, if you use JControllerLegacy, the new Joomla MVC will use the class \Joomla\CMS\MVC\Controller\BaseController namespace.

So, for interpreting, I looked at the category modal for Sermon Distributor. It is using JModelList. So, looking at the alias I can see that for the new classes the alias is JLoader::registerAlias('JModelList', '\Joomla\CMS\MVC\Model\ListModel', '5.0');.

So, the code goes from class SermondistributorModelCategory extends JModelList to:

use Joomla\CMS\MVC\Model\ListModel;
class SermondistributorModelCategory extends ListModel

However, I do think it would be good to have the ability to add additional namespaces. For example, on category I also added use Joomla\CMS\Table\Category; as a namespace, which then uses the category table class in addition to the ListModel.

Here's a joomla! magazine article about the new MVC from 2013: https://magazine.joomla.org/issues/issue-nov-2013/item/1580-new-mvc-for-joomla-cms

joomla_mvc_classes.txt

Absolutely. These examples are for site controllers and views, but it should be similar for admin. *** For controller, JCB currently uses: class DemoControllerLook extends JControllerForm Change it to : use Joomla\CMS\MVC\Controller\BaseController; class DemoControllerLook extends BaseController *** For models, JCB currently uses: class DemoModelLooks extends JModelList change to use Joomla\CMS\MVC\Model\ListModel; class DemoModelCategory extends ListModel Attached is a list of what the "old" class is, and what the new class is. Joomla currently has them setup as aliases. So, if you use JControllerLegacy, the new Joomla MVC will use the class \Joomla\CMS\MVC\Controller\BaseController namespace. So, for interpreting, I looked at the category modal for Sermon Distributor. It is using JModelList. So, looking at the alias I can see that for the new classes the alias is JLoader::registerAlias('JModelList', '\\Joomla\\CMS\\MVC\\Model\\ListModel', '5.0');. So, the code goes from class SermondistributorModelCategory extends JModelList to: use Joomla\CMS\MVC\Model\ListModel; class SermondistributorModelCategory extends ListModel However, I do think it would be good to have the ability to add additional namespaces. For example, on category I also added use Joomla\CMS\Table\Category; as a namespace, which then uses the category table class in addition to the ListModel. Here's a joomla! magazine article about the new MVC from 2013: [https://magazine.joomla.org/issues/issue-nov-2013/item/1580-new-mvc-for-joomla-cms](https://magazine.joomla.org/issues/issue-nov-2013/item/1580-new-mvc-for-joomla-cms) [joomla_mvc_classes.txt](https://github.com/vdm-io/Joomla-Component-Builder/files/3076793/joomla_mvc_classes.txt)
mwweb commented 2019-04-13 22:39:02 +00:00 (Migrated from github.com)

For views, here is an example:

class SermondistributorViewPreachers extends JViewLegacy

Becomes:

use Joomla\CMS\MVC\View\HtmlView;

class SermondistributorViewPreachers extends HtmlView

For views, here is an example: class SermondistributorViewPreachers extends JViewLegacy Becomes: use Joomla\CMS\MVC\View\HtmlView; class SermondistributorViewPreachers extends HtmlView
mwweb commented 2019-04-13 22:45:58 +00:00 (Migrated from github.com)

This link, too, might be helpful. I'm going to paste this link in the Joomla 4 JCB project:

https://joomla.digital-peak.com/images/blog/JWC17_Prepare_you_extension_for_Joomla_4.pdf

This link, too, might be helpful. I'm going to paste this link in the Joomla 4 JCB project: [https://joomla.digital-peak.com/images/blog/JWC17_Prepare_you_extension_for_Joomla_4.pdf](https://joomla.digital-peak.com/images/blog/JWC17_Prepare_you_extension_for_Joomla_4.pdf)

Okay most of these changes are really as you know part of the new Joomla4. I am aware of all the depreciation and the backward compatibility measures.

The full implementation of these changes will be made once we adapt JCB to compile a fully native Joomla4 component.

Our current roadmap is aiming to release JCB ready for Joomla 4 soon after the official stable Joomla 4 is released. Yet to also insure the components build with JCB will run on Joomla 3.9 and 4 in legacy mode even before the official release. This does not require the same amount of changes. This roadmap will allow us to focus on new behavior in JCB and not as much the compiler at this time.

You should know the compiler and the JCB gui/interface (behavior) are somewhat decoupled to allow easy migration of components to a better Joomla 4 convention and implementation.

I am closing this issue, but once this enhancement is made I will reference it again, and you are also welcome to continue commenting here if any info you think we need becomes available.

Okay most of these changes are really as you know part of the new Joomla4. I am aware of all the depreciation and the backward compatibility measures. The full implementation of these changes will be made once we adapt JCB to compile a fully native Joomla4 component. Our current roadmap is aiming to release **JCB ready for Joomla 4** soon after the official stable Joomla 4 is released. Yet to also insure the components build with JCB will run on Joomla 3.9 and 4 in legacy mode even before the official release. This does not require the same amount of changes. This roadmap will allow us to focus on new behavior in JCB and not as much the compiler at this time. You should know the compiler and the JCB gui/interface (behavior) are somewhat decoupled to allow easy migration of components to a better Joomla 4 convention and implementation. I am closing this issue, but once this enhancement is made I will reference it again, and you are also welcome to continue commenting here if any info you think we need becomes available.
Sign in to join this conversation.
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: joomla/Component-Builder#405
No description provided.