--
You received this message because you are subscribed to the Google Groups "Joomla! CMS Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-cm...@googlegroups.com.
To post to this group, send an email to joomla-...@googlegroups.com.
Visit this group at https://groups.google.com/group/joomla-dev-cms.
For more options, visit https://groups.google.com/d/optout.
Depending on what the trigger is, why not just contribute the change to core?When using JLoader::register(), you must pass the fully qualified class name as the first argument. You aren't passing the namespace info in, that's why the autoloader won't pick up your class. If you haven't already, I suggest taking a look at PHP's documentation for how namespaces work.
On Tue, Apr 2, 2019 at 6:23 AM UWiX <nva...@gmail.com> wrote:
I cannot seem to figure out how to override a Model in J!4 - so I hope someone can help me out, here.
What I want to do is log the "publish" state for an Extension which can be toggled in the Extension Manager.
In J!3 this can be done using a system plugin and add the following code to the onAfterRoute() function:
JLoader::register('InstallerModelManage', JPATH_PLUGINS . '/system/myplugin/overrides/manage.php');
That manage.php file is an exact copy of the manage.php model from the com_installer directory in J!3. It only has a trigger added to it's publish() function. That works perfectly in J!3.
Now I want to accomplish the same for J!4 and did the same with the ManageModel.php file from the com_installer folder. But somehow the JLoader::register isn't enough:
JLoader::register('ManageModel', JPATH_PLUGINS . '/system/myplugin/overrides/ManageModel.php');
Above code should do the trick - that is in J!3 but not for J!4. I've already remarked the namespace for my override ManageModel.php file (I've read somewhere that is needed).
When I check the loaded ClassList using JLoader::getClassList() I see the override Model is loaded but it isn't used whatsoever.
At this moment I've tried everything from the require_once() to JLoader::import, JLoader::registerNamespace, etc. But nothing seems to load my override Model.
What am I missing here? Does anyone have a suggestion? Thanks!
--
You received this message because you are subscribed to the Google Groups "Joomla! CMS Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-cm...@googlegroups.com.
To post to this group, send email to joomla-...@googlegroups.com.
To post to this group, send email to joomla-...@googlegroups.com.