I am trying to create a hook extension for Contao. But Contao doesn't seem to be able to load my class from the namespace, which handles the hook. This is my file structure:
I have tried changing names and added ".php" to the class, looked up tutorials, but I can't find what I am doing wrong. I am fairly inexperienced in this topic, so I might be missing something obvious.
autoload.php
ClassLoader::addNamespaces(array
(
'Memberlevels',
));
gister PSR-0 namespace
*/
if (class_exists('NamespaceClassLoader')) {
NamespaceClassLoader::add('Memberlevels', 'system/modules/memberlevels/classes');
}
if (class_exists('NamespaceClassLoader')) {
NamespaceClassLoader::addClassMap(array
(
'Memberlevels' => 'system/modules/memberlevels/classes/myClass.php'
));
}
/*
* Register the templates
*/
TemplateLoader::addFiles([
'cookiebar' => 'system/modules/memberlevels/templates',
]);
config.php
$GLOBALS['TL_HOOKS']['outputBackendTemplate'][] = array('Memberlevels\myClass', 'myOutputBackendTemplate');
I get the error message:
Attempted to load class "myClass" from namespace "Memberlevels". Did you forget a "use" statement for another namespace?