Open arenamax opened 2 years ago
I confirm the problem.
In /components/com_ajax/ajax.php
$moduleInstance = $app->bootModule('mod_' . $module, $app->getName());
no helper class returned for a helper file in a subdirectory /src/Helper.
As a solution can use: https://github.com/dgrammatiko/invalidate-cache/blob/d19f7f1b6b375dfcc4417d84c8ac3697097a84fd/src/invalidatecache/services/provider.php
But that's not good, I think.
But that's not good, I think.
This is the Joomla 4 way which is not 100% B/C because of namespacing...
Creating a separate file in a module just to be able to use com_ajax is definitely a problem.
I don't understand why when com_ajax knows the exact location and file name of a module class, we have to load that class manually in a separate file.
Also, there is no documentation about this in the com_ajax usage description.
Running into the same issue.
In J4 Module Helper are namespaced and in src directory. com_ajax is apparently not able to load this helper file and then falls back to J3 file locations > 'mod_module'/helper.php which is not correct.
You can try this yourself on a J4 site: [yourdomain/index.php?option=com_ajax&module=articles_news&method=test&format=raw (note: a Joomla core module!)
which results in: RuntimeException: The file at mod_articles_news/helper.php does not exist.
Closing as having a pull request. Please test #37398 . Thanks in advance.
Ajax is not available by namespace!
Steps to reproduce the issue
Namespace from install xml
js
AmapHelper.php
path 'modules/mod_amap/src/Helper/AmapHelper.php'
Expected result
JSON data
Actual result
Console log
System information (as much as possible)
Joomla v. 4.1.0-rc4 PHP 7.4.27