Skip to content
10 changes: 8 additions & 2 deletions libraries/namespacemap.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('_JEXEC') or die;
defined('JPATH_PLATFORM') or die;

use Joomla\CMS\Filesystem\File;
use Joomla\CMS\Filesystem\Folder;
Expand Down Expand Up @@ -65,6 +65,7 @@ public function create()
$extensions = array_merge(
$this->getNamespaces('component'),
$this->getNamespaces('module'),
$this->getNamespaces('template'),
$this->getNamespaces('plugin'),
$this->getNamespaces('library')
);
Expand Down Expand Up @@ -139,7 +140,7 @@ protected function writeNamespaceFile($elements)
*/
private function getNamespaces(string $type): array
{
if (!in_array($type, ['component', 'module', 'plugin', 'library'], true))
if (!in_array($type, ['component', 'module', 'plugin', 'template', 'library'], true))
{
return [];
}
Expand All @@ -153,6 +154,10 @@ private function getNamespaces(string $type): array
{
$directories = [JPATH_SITE . '/modules', JPATH_ADMINISTRATOR . '/modules'];
}
elseif ($type === 'template')
{
$directories = [JPATH_SITE . '/templates', JPATH_ADMINISTRATOR . '/templates'];
}
elseif ($type === 'plugin')
{
$directories = Folder::folders(JPATH_PLUGINS, '.', false, true);
Expand All @@ -173,6 +178,7 @@ private function getNamespaces(string $type): array

// Strip the com_ from the extension name for components
$name = str_replace('com_', '', $extension, $count);
$name = $type === 'template' ? 'templateDetails' : $name;
$file = $extensionPath . $name . '.xml';

// If there is no manifest file, ignore. If it was a component check if the xml was named with the com_ prefix.
Expand Down