A partir de Joomla 3.8, les classes Jxxx. sont renommées.
Le loader a été modifié pour changer les noms dynamiquement et conserver la compatibilité, ceci jusqu’à Joomla 4, et certainement même Joomla 5.
Voici donc les changements à faire progressivement.
L’intérêt est que l'IDE que vous utilisez soit capable de faire la liaison avec la classe utilisée, par exemple pour conserver la complétion automatique.
Si vous développez, ne mettez plus le J quand vous appelez la classe et dans ce cas ajoutez juste le use, sans le as.
Si vos développements sont déjà fait (et donc que vous appelez les classe avec le J devant, déclarez la classe avec les use... as J....
Ancienne classe | Devient | Use | Observation ou emplacement |
JAccess | Joomla\CMS\Access\Access | use Joomla\CMS\Access\Access as JAccess; | /libraries/src/Access/access.php |
JAccessExceptionNotallowed | Joomla\CMS\Access\Exception\NotAllowed | use Joomla\CMS\Access\Exception\NotAllowed as JAccessExceptionNotallowed ; | |
JAccessRules | Joomla\CMS\Access\Rules | use Joomla\CMS\Access\Rules as JAccessRules; | /libraries/src/Access/Rules.php |
JApplicationHelper | Joomla\CMS\Application\ApplicationHelper | use Joomla\CMS\Application\ApplicationHelper as JApplicationHelper; | |
JArrayHelper | Joomla\Utilities\ArrayHelper | use Joomla\Utilities\ArrayHelper as JArrayHelper; | deprecated 4.0 Use Joomla\Utilities\ArrayHelper instead /librairies/vendor/Joomla/utilities/src/ArrayHelper.php |
JArchive | Joomla\Archive\Archive | use Joomla\Archive\Archive as JArchive; | /librairies/vendor/Joomla/archive/src/Archive.php |
JAuthentication | \Joomla\CMS\Authentication\Authentication | use \Joomla\CMS\Authentication\Authentication as JAuthentication | /librairies/src/Authentication/Authentication.php |
JBrowser | Joomla\CMS\Environment\Browser | use Joomla\CMS\Environment\Browser as JBrowser; | /libraries/src/Environment/Browser.php |
Cache | Joomla\CMS\Cache\Cache; | use Joomla\CMS\Cache\Cache; | |
JCacheController | Joomla\CMS\Cache\CacheController | use Joomla\CMS\Cache\CacheController as JCacheController | |
CacheControllerFactoryInterface | use Joomla\CMS\Cache\CacheControllerFactoryInterface; | ||
CacheExceptionInterface | use Joomla\CMS\Cache\Exception\CacheExceptionInterface; | ||
JCategories | Joomla\CMS\Categories\Categories | use Joomla\CMS\Categories\Categories as JCategories; | /libraries/src/Categories/Categories.php |
JCategoryNode | Joomla\CMS\Categories\CategoryNode | use Joomla\CMS\Categories\CategoryNode as JCategoryNode; | /libraries/src/Categories/CategoryNode.php |
JClientHelper | Joomla\CMS\Client\ClientHelper | use Joomla\CMS\Client\ClientHelper as JClientHelper; | |
JComponentHelper | Joomla\CMS\Component\ComponentHelper | use Joomla\CMS\Component\ComponentHelper as JComponentHelper; | |
JComponentRouterBase | Joomla\CMS\Component\Router\RouterBase | use Joomla\CMS\Component\Router\RouterBase as JComponentRouterBase | /libraries/src/Component/Router/RouterBase.php |
JComponentRouterLegacy | Joomla\CMS\Component\Router\RouterLegacy | use Joomla\CMS\Component\Router\RouterLegacy as JComponentRouterLegacy | |
JComponentRouterRulesInterface | Joomla\CMS\Component\Router\Rules\RulesInterface | use Joomla\CMS\Component\Router\Rules\RulesInterface as JComponentRouterRulesInterface; | /libraries/src/Component/Router/Rules/RulesInterface.php |
JComponentRouterView | Joomla\CMS\Component\Router\RouterView | use Joomla\CMS\Component\Router\RouterView as JComponentRouterView; | /libraries/src/Component/Router/RouterView.php |
JControllerAdmin | Joomla\CMS\MVC\Controller\AdminController | use Joomla\CMS\MVC\Controller\AdminController as JControllerAdmin; | |
JControllerForm | Joomla\CMS\MVC\Controller\FormController | use Joomla\CMS\MVC\Controller\FormController as JControllerForm; | |
JControllerLegacy | Joomla\CMS\MVC\Controller\BaseController | use Joomla\CMS\MVC\Controller\BaseController as JControllerLegacy; | |
JDate | Joomla\CMS\Date\Date | use Joomla\CMS\Date\Date as JDate; | |
JDataBaseDriver | /librairies/joomla/database/driver | ||
JErrorPage | Joomla\CMS\Exception\ExceptionHandler | ne pas déclarer | /libraries/src/Exception/ExceptionHandler.php |
JEventDispatcher | J4.0:the CMS' Event classes... | ...will be replaced with the `joomla/event` package | /librairies/joomla/event/dispatcher.php |
JFactory | Joomla\CMS\Factory | use Joomla\CMS\Factory as JFactory; | |
JFile | Joomla\CMS\Filesystem\File | use Joomla\CMS\Filesystem\File as JFile; | |
JFilterInput | Joomla\CMS\Filter\InputFilter | use Joomla\CMS\Filter\InputFilter as JFilterInput; | |
JFilterOutput | Joomla\CMS\Filter\OutputFilter | use Joomla\CMS\Filter\OutputFilter as JFilterOutput; | /libraries/src/Filter/OutputFilter.php |
JFolder | Joomla\CMS\Filesystem\Folder | use Joomla\CMS\Filesystem\Folder as JFolder; | |
JForm | Joomla\CMS\Form\Form | use Joomla\CMS\Form\Form as JForm; | |
JFormField | Joomla\CMS\Form\FormField | use Joomla\CMS\Form\FormField as JFormField; | /libraries/src/Form/FormField.php |
JFormFieldList | Joomla\CMS\Form\Field\ListField | use Joomla\CMS\Form\Field\ListField as JFormFieldList; | |
JFormFieldGroupedList | \Joomla\CMS\Form\Field\GroupedlistField | use \Joomla\CMS\Form\Field\GroupedlistField as JFormFieldGroupedList; | |
JformHelper | Joomla\CMS\Form\FormHelper | use Joomla\CMS\Form\FormHelper as JformHelper; | |
JFormRule | Joomla\CMS\Form\FormRule | use Joomla\CMS\Form\FormRule as JFormRule; | |
JHelperContent | Joomla\CMS\Helper\ContentHelper | use Joomla\CMS\Helper\ContentHelper as JHelperContent; | |
JHelperTags | Joomla\CMS\Helper\Tagshelper | use Joomla\CMS\Helper\Tagshelper as JHelperTags; | |
JHtml | Joomla\CMS\HTML\HTMLHelper | use Joomla\CMS\HTML\HTMLHelper as JHtml; | |
JHtmlSidebar | Joomla\CMS\HTML\Helpers\Sidebar | use Joomla\CMS\HTML\Helpers\Sidebar as JHtmlSidebar; | |
JHttpFactory | Joomla\CMS\Http\HttpFactory | use Joomla\CMS\Http\HttpFactory as JHttpFactory | /libraries/src/Http/HttpFactory.php |
JHtmlGrid | use \Joomla\CMS\HTML\Helpers\Grid as JHtmlGrid; | ||
JImage | Joomla\CMS\Image\Image | use Joomla\CMS\Image\Image as JImage; | |
Jinput | \Joomla\CMS\Input\Input | use \Joomla\CMS\Input\Input as Jinput; | /libraries/vendor/joomla/input/src/Input.php |
JInstallerComponent | Joomla\CMS\Installer\Adapter\ComponentAdapter | use Joomla\CMS\Installer\Adapter\ComponentAdapter as JInstallerComponent; | /librairies/src/Installer/Adapter/ComponentAdapter.php |
JInstallerHelper | Joomla\CMS\Installer\InstallerHelper | use Joomla\CMS\Installer\InstallerHelper as JInstallerHelper; | |
JLanguage | Joomla\CMS\Language\Language | use Joomla\CMS\Language\Language as JLanguage | |
JLanguageAssociations | Joomla\CMS\Language\Associations | use Joomla\CMS\Language\Associations as JLanguageAssociations; | /librairies/src/Language/Associations.php |
JLanguageHelper | Joomla\CMS\Language\LanguageHelper | use Joomla\CMS\Language\LanguageHelper as JLanguageHelper; | /librairies/src/Language/LanguageHelper.php |
JLanguageMultilang | Joomla\CMS\Language\Multilanguage | use Joomla\CMS\Language\Multilanguage as JLanguageMultilang; | /librairies/src/Language/Multilanguage.php |
JLayoutFile | Joomla\CMS\Layout\BaseLayout | use Joomla\CMS\Layout\BaseLayout as JLayoutFile; | /librairies/src/Layout/FileLayout.php |
JLayoutHelper | Joomla\CMS\Layout\LayoutHelper | use Joomla\CMS\Layout\LayoutHelper as JLayoutHelper; | |
JLoader | use JLoader | /libraries/loader.php | |
JLog | Joomla\CMS\Log\Log | use \Joomla\CMS\Log\Log as JLog; | |
JMailer | Joomla\CMS\Mail | use Joomla\CMS\Mail as JMailer; | utiliser \Joomla\CMS\Factory::getMailer() pour obtenir la classe |
JMailHelper | Joomla\CMS\Mail\MailHelper | use Joomla\CMS\Mail\MailHelper as JMailHelper | /libraries/src/Mail/MailHelper.php |
Jmenu | \Joomla\CMS\Menu\AbstractMenu | use \Joomla\CMS\Menu\AbstractMenu as JMenu; | /libraries/scr/Menu/AbstractMenu.php |
JMicrodata | \Joomla\CMS\Microdata\Microdata | use \Joomla\CMS\Microdata\Microdata as JMicrodata; | |
JModelAdmin | Joomla\CMS\MVC\Model\AdminModel | use Joomla\CMS\MVC\Model\AdminModel as JModelAdmin; | |
JModelForm | \Joomla\CMS\MVC\Model\FormModel | use \Joomla\CMS\MVC\Model\FormModel as JModelForm; | |
JModelItem | Joomla\CMS\MVC\Model\ItemModel | use Joomla\CMS\MVC\Model\ItemModel as JModelItem; | |
JModelLegacy | Joomla\CMS\MVC\Model\BaseDatabaseModel | use Joomla\CMS\MVC\Model\BaseDatabaseModel as JModelLegacy; | /libraries/src/MVC/Model/BaseDataBaseModel.php |
JModelList | Joomla\CMS\MVC\Model\ListModel | use Joomla\CMS\MVC\Model\ListModel as JModelList; | |
JObject | Joomla\CMS\Object\CMSObject | use Joomla\CMS\Object\CMSObject as JObject; | /libraries/src/Object/CMSObject.php |
JPagination | Joomla\CMS\Pagination\Pagination | use Joomla\CMS\Pagination\Pagination as JPagination; | /libraries/src/Pagination/Pagination.php |
JPath | Joomla\CMS\Filesystem\Path | use Joomla\CMS\Filesystem\Path as JPath; | /libraries/src/Filesystem/Path.php |
JPlugin | Joomla\CMS\Plugin\CMSPlugin | use Joomla\CMS\Plugin\CMSPlugin as JPlugin; | /libraries/src/Plugin/CMSPlugin.php |
JPluginHelper | Joomla\CMS\Plugin\PluginHelper | use Joomla\CMS\Plugin\PluginHelper as JPluginHelper; | |
JRegistry | Joomla\Registry\Registry | use Joomla\Registry\Registry as JRegistry; | |
JRoute | Joomla\CMS\Router\Route | use Joomla\CMS\Router\Route as JRoute; | |
JRouter | Joomla\CMS\Router\Router | use Joomla\CMS\Router\Router as JRouter | |
JRouterSite | Joomla\CMS\Router\SiteRouter | use Joomla\CMS\Router\SiteRouter as JRouterSite | /libraries/src/Router/SiteRouter.php |
JSession | Joomla\CMS\Session\Session | use Joomla\CMS\Session\Session as JSession; | |
JStream | Joomla\CMS\Filesystem\Stream | use Joomla\CMS\Filesystem\Stream as JStream; | |
JStringPunycode | Joomla\CMS\String\PunycodeHelper | use Joomla\CMS\String\PunycodeHelper as JStringPunycode; | /librairies/src/String/PunycodeHelper.php |
JTable | Joomla\CMS\Table\Table | use Joomla\CMS\Table\Table as JTable; | |
JTableCategory | Joomla\CMS\Table\Category | use Joomla\CMS\Table\Category as JTableCategory; | |
TableInterface | Joomla\CMS\Table\TableInterface | use Joomla\CMS\Table\TableInterface; | |
JText | Joomla\CMS\Language\Text | use Joomla\CMS\Language\Text as JText; | |
JToolbar | Joomla\CMS\Toolbar\Toolbar | use Joomla\CMS\Toolbar\Toolbar as JToolbar; | |
JToolbarHelper | Joomla\CMS\Toolbar\ToolbarHelper | use Joomla\CMS\Toolbar\ToolbarHelper as JToolbarHelper; | |
JUcmType | Joomla\CMS\UCM\UCMType | use Joomla\CMS\UCM\UCMType as JUcmType; | /librairies/src/UCM/UCMType.php |
JUri | Joomla\CMS\Uri\Uri | use Joomla\CMS\Uri\Uri as JUri; | |
JUser | Joomla\CMS\User\User | use Joomla\CMS\User\User as JUser; | |
JUserHelper | Joomla\CMS\User\UserHelper | use Joomla\CMS\User\UserHelper as JUserHelper; | |
JVersion | Joomla\CMS\Version | use Joomla\CMS\Version as JVersion; | |
JViewcategories | Joomla\CMS\MVC\View\CategoriesView | use Joomla\CMS\MVC\View\CategoriesView as JViewCategories; | /libraries/src/MVC/View/CategoriesView.php |
JViewCategory | Joomla\CMS\MVC\View\CategoryView | use Joomla\CMS\MVC\View\CategoryView as JViewCategory; | /libraries/src/MVC/View/CategoryView.php |
JViewLegacy | Joomla\CMS\MVC\View\HtmlView | use Joomla\CMS\MVC\View\HtmlView as JViewLegacy; | /libraries/src/MVC/View/HtmlView.php |
Je compléterai ce tableau progressivement.
Donc 2 formules (exemple pour JFactory) :
- soit on remplace par exemple : JFactory::getApplication() par \Joomla\CMS\Factory::getApplication()
- soit on place tout au début des scripts : use Joomla\CMS\Factory as JFactory;
Personnellement je préfere la 2ème formule.
En fait en execution le loader se débrouille et trouve les Classes.
C'est juste avec un IDE que l'IDE ne s'en sort par et vous avez des erreurs.
De plus vous perdez l'autocompletion, et la description des fonctions.
Voir aussi : /librairies/classmap.php
Voir aussi : https://github.com/nikosdion/joomlatypehints/blob/main/JoomlaObsoleteClasses.md