Skip to content

Commit

Permalink
Make bundle Contao 5.5 compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
bytehead committed Jan 7, 2025
1 parent f06de10 commit 1837deb
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 0 deletions.
2 changes: 2 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@
"symfony/dependency-injection": "^6.4 || ^7.0",
"symfony/http-foundation": "^6.4 || ^7.0",
"symfony/http-kernel": "^6.4 || ^7.0",
"symfony/routing": "^6.4 || ^7.0",
"symfony/security-bundle": "^6.4 || ^7.0",
"symfony/security-core": "^6.4 || ^7.0",
"symfony/translation": "^6.4 || ^7.0",
"twig/twig": "^3.8"
},
"require-dev": {
Expand Down
7 changes: 7 additions & 0 deletions config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ services:
tags:
- { name: contao.callback, table: tl_user, target: config.onload }

contao_id_contao.event_listener.menu.backend_login_listener:
class: ContaoId\ContaoBundle\EventListener\Menu\BackendLoginListener
arguments:
- '@translator'
- '@router'
tags: [kernel.event_listener]

contao_id_contao.event_listener.user_icon_listener:
class: ContaoId\ContaoBundle\EventListener\UserIconListener
arguments:
Expand Down
6 changes: 6 additions & 0 deletions public/contao-id--dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions public/contao-id.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 41 additions & 0 deletions src/EventListener/Menu/BackendLoginListener.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

declare(strict_types=1);

namespace ContaoId\ContaoBundle\EventListener\Menu;

use Contao\CoreBundle\Event\MenuEvent;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Contracts\Translation\TranslatorInterface;

class BackendLoginListener
{
public function __construct(
private readonly TranslatorInterface $translator,
private readonly RouterInterface $router,
) {
}

public function __invoke(MenuEvent $event): void
{
$tree = $event->getTree();

if ('loginMenu' !== $tree->getName()) {
return;
}

$contaoId = $event->getFactory()
->createItem('contaoid')
->setAttribute('class', 'contaoid')
->setLabel($this->translator->trans('login.button', [], 'ContaoIdContao'))
->setUri($this->router->generate('hwi_oauth_service_redirect', ['service' => 'contao_id']))
->setLinkAttribute('class', 'tl_submit has-icon')
->setExtra('icon', '/bundles/contaoidcontao/contao-id.svg')
->setExtra('icon_dark', '/bundles/contaoidcontao/contao-id--dark.svg')
->setExtra('safe_label', true)
->setExtra('translation_domain', false)
;

$tree->addChild($contaoId);
}
}

0 comments on commit 1837deb

Please sign in to comment.