There's many places in the system using JTable::getInstance
to get component table objects, that have broken since namespacing. Especially of importance is the multilanguage install in Joomla 3.x - but there several other places. Not sure what the best way to solve this is - the MVC Helper???
Labels |
Added:
?
|
Category | ⇒ | Code style |
To make all the legacy code JTable::getInstance
work again in 4, the extension classmap needs to be extended with all core tables as we already did in #16435 here https://github.com/joomla/joomla-cms/blame/4.0-dev/libraries/extensions.classmap.php#L16.
By the way we have the same issue with models JModelLegacy::getInstance
does also not work anymore.
Status | New | ⇒ | Discussion |
A quick update on this issue here. It all comes down to the question to what degree we want to make it possible to let the model and table objects instanciation being overrideable. At the moment the getInstance calls of JModelLegacy::getInstance has been replaced by direct creating the object, for example here https://github.com/joomla/joomla-cms/blob/4.0-dev/administrator/modules/mod_latest/mod_latest.php#L15. If we want to go more the service way, then it needs a bigger rewrite of the MVCFactory.
We shouldn't be direct instantiating anything in the MVC layer except for inside factories. The current getInstance()
methods allow a semi-clean way to overload component classes and the direct instantiation method basically means that the only way to accomplish it is with autoloader manipulation. As much as I disagree with the concept of class overloading, I do agree with being able to override the logic to load objects (I'd rather people be able to subclass things and put their customizations in place versus encouraging core classes to be overloaded since at that point you can't rely on the API being stable and that's where you get the bug reports about missing methods in core classes after an upgrade) so we should try our hardest to make use of the factories and only go to a direct instantiation model if we can't make it work.
Lets take the example of the sample data blog plugin which needs models from different extensions. To properly fix it, I see two possible ways:
$container->get(MVCFactoryFactoryInterface::class)->createFactory('Joomla\\Component\\Content')->createModel('Articles', 'Administrator');
$container->get(MVCFactoryFactoryInterface::class)->createFactory('Joomla\\Component\\Categories\')->createModel('Category', 'Administrator');
$factory = new MVCFactory('', $app);
$factory->createModel(ArticlesModel::class);
$factory->createModel(CategoryModel::class);
Closed_Date | 2018-03-05 11:02:27 | ⇒ | 2018-03-05 11:02:28 |
Closed_By | franz-wohlkoenig | ⇒ | joomla-cms-bot |
Status | Discussion | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2018-03-05 11:02:27 |
Closed_By | ⇒ | franz-wohlkoenig |
Set to "closed" on behalf of @franz-wohlkoenig by The JTracker Application at issues.joomla.org/joomla-cms/17705
I believe @laoneo is going to work on this next week :)