Skip to content

Commit

Permalink
Fix Contao 5.3 compatibility (#73)
Browse files Browse the repository at this point in the history
* fix symfony 6 service subscriber compatibility

* code enhancements

* remove abstract service subscriber

* adjust workflow

* final cleanup
  • Loading branch information
koertho authored Feb 19, 2024
1 parent dbc1e71 commit 9bef6c3
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 56 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [ 8.1, 8.2 ]
contao: [ 4.13.*, 5.2.* ]
php: [ 8.1, 8.2, 8.3 ]
contao: [ 4.13.*, 5.3.* ]

steps:
- name: Setup PHP
Expand Down Expand Up @@ -65,7 +65,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
php-version: 8.3

- name: Checkout
uses: actions/checkout@v2
Expand Down
6 changes: 2 additions & 4 deletions src/EventListener/DcaAuthorListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@

class DcaAuthorListener
{
/** @var ContaoFramework */
private $framework;
/** @var Security */
private $security;
private ContaoFramework $framework;
private Security $security;

public function __construct(ContaoFramework $framework, Security $security)
{
Expand Down
1 change: 0 additions & 1 deletion src/HeimrichHannotUtilsBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

namespace HeimrichHannot\UtilsBundle;

use HeimrichHannot\UtilsBundle\DependencyInjection\HeimrichHannotUtilsExtension;
use Symfony\Component\HttpKernel\Bundle\Bundle;

class HeimrichHannotUtilsBundle extends Bundle
Expand Down
26 changes: 0 additions & 26 deletions src/Util/AbstractServiceSubscriber.php

This file was deleted.

8 changes: 3 additions & 5 deletions src/Util/ContainerUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,12 @@

namespace HeimrichHannot\UtilsBundle\Util;

use Contao\CoreBundle\ContaoCoreBundle;
use Contao\CoreBundle\Framework\ContaoFramework;
use Contao\CoreBundle\Monolog\ContaoContext;
use Contao\CoreBundle\Routing\ScopeMatcher;
use Contao\CoreBundle\Security\Authentication\Token\TokenChecker;
use Contao\Input;
use Contao\PageModel;
use Contao\System;
use HeimrichHannot\UtilsBundle\Util\AbstractServiceSubscriber;
use Psr\Container\ContainerInterface;
use Psr\Log\LoggerInterface;
use Psr\Log\LogLevel;
Expand All @@ -25,8 +22,9 @@
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpKernel\Config\FileLocator;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Contracts\Service\ServiceSubscriberInterface;

class ContainerUtil extends AbstractServiceSubscriber
class ContainerUtil implements ServiceSubscriberInterface
{
public function __construct(
private ContainerInterface $locator,
Expand Down Expand Up @@ -173,7 +171,7 @@ public function isPreviewMode(): bool
&& $this->framework->getAdapter(Input::class)->cookie('FE_PREVIEW');
}

public static function getSubscribedServices()
public static function getSubscribedServices(): array
{
return [
'monolog.logger.contao' => LoggerInterface::class,
Expand Down
4 changes: 0 additions & 4 deletions src/Util/RoutingUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,14 @@
namespace HeimrichHannot\UtilsBundle\Util;

use Contao\CoreBundle\Csrf\ContaoCsrfTokenManager;
use HeimrichHannot\UtilsBundle\Util\AbstractServiceSubscriber;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\ContainerInterface;
use Psr\Container\NotFoundExceptionInterface;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;

class RoutingUtil
{

public function __construct(
private ContaoCsrfTokenManager $tokenManager,
private RouterInterface $router,
Expand Down
16 changes: 3 additions & 13 deletions src/Util/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,10 @@

namespace HeimrichHannot\UtilsBundle\Util;

use HeimrichHannot\UtilsBundle\Util\DatabaseUtil;
use HeimrichHannot\UtilsBundle\Util\DcaUtil;
use HeimrichHannot\UtilsBundle\Util\HtmlUtil;
use HeimrichHannot\UtilsBundle\Util\LocaleUtil;
use HeimrichHannot\UtilsBundle\Util\RequestUtil;
use HeimrichHannot\UtilsBundle\Util\UrlUtil;
use HeimrichHannot\UtilsBundle\Util\RoutingUtil;
use HeimrichHannot\UtilsBundle\Util\ArrayUtil;
use HeimrichHannot\UtilsBundle\Util\StringUtil;
use HeimrichHannot\UtilsBundle\Util\AccordionUtil;
use HeimrichHannot\UtilsBundle\Util\UserUtil;
use Psr\Container\ContainerInterface;
use Symfony\Contracts\Service\ServiceSubscriberInterface;

class Utils extends AbstractServiceSubscriber
class Utils implements ServiceSubscriberInterface
{
/**
* @var ContainerInterface
Expand Down Expand Up @@ -116,7 +106,7 @@ public function user(): UserUtil
return $this->locator->get(UserUtil::class);
}

public static function getSubscribedServices()
public static function getSubscribedServices(): array
{
return [
AccordionUtil::class,
Expand Down

0 comments on commit 9bef6c3

Please sign in to comment.