Zitat von
Spooky
Brauchst du die Kompatibilität unbedingt? Contao 4.4 bekommt Bugfix Updates ja eh nur mehr bis Ende dieses Jahres
Poste mal die Implementierung des Hooks.
Die Kompatibilität wäre schon Top, da ich das gerne noch in ein paar alten Systemen einsetzen würde.
Wenn es gar nicht anders geht, muss ich da wohl drauf verzichten, aber da gibt es sicher einen Weg
Das ist der Hook selbst:
PHP-Code:
namespace Agentur1601com\CoreBundle\EventListener;
use Contao\CoreBundle\ServiceAnnotation\Hook;
use Symfony\Component\Routing\RouterInterface;
/**
* @Hook("getUserNavigation")
*/
class GetUserNavigationListener
{
private $_routerInterface;
public function __construct(RouterInterface $_routerInterface)
{
$this->_routerInterface = $_routerInterface;
}
/**
* @param array $modules
* @param bool $showAll
* @return array
*/
public function __invoke(array $modules, bool $showAll): array
{
$modules['agentur1601com']['modules']['core'] = [
'label' => 'Unterstützen',
'title' => 'The core bundle',
'class' => 'agentur1601com',
'href' => $this->_routerInterface->generate('agentur1601com_core_backend'),
];
return $modules;
}
}
Das ist meine contao/config.php:
PHP-Code:
<?php
// Backend menu
array_insert($GLOBALS['BE_MOD'], array_search('system', array_keys($GLOBALS['BE_MOD'])) + 1, array
(
'agentur1601com' => [
'core' => [
],
]
));
// Hook for backend menu entry
$GLOBALS['TL_HOOKS']['getUserNavigation'][] = ['Agentur1601com\\CoreBundle\\EventListener\\GetUserNavigationListener', '__invoke'];
// Load backend style sheet
if (TL_MODE == "BE") {
$GLOBALS['TL_CSS'][] = '/bundles/agentur1601comcore/css/be_core_style.css';
}
Und die services.yml:
PHP-Code:
services:
_defaults:
autoconfigure: true
autowire: true
Agentur1601com\CoreBundle\EventListener\GetUserNavigationListener:
public: true
Der Hook funktioniert ja, wird ja alles richtig dargestellt, aber eben nur als Admin-User.
Als Non-Admin wirkt es so, als würde hier etwas nicht richtig dargestellt werden.
Da fehlen auch Klassen im Styling und der html-Aufbau ist anders.
Lesezeichen