From 9bef6c3ef3a7ea193041d09b1e5deedc410b7560 Mon Sep 17 00:00:00 2001 From: Thomas Date: Mon, 19 Feb 2024 10:03:54 +0100 Subject: [PATCH] Fix Contao 5.3 compatibility (#73) * fix symfony 6 service subscriber compatibility * code enhancements * remove abstract service subscriber * adjust workflow * final cleanup --- .github/workflows/ci.yml | 6 +++--- src/EventListener/DcaAuthorListener.php | 6 ++---- src/HeimrichHannotUtilsBundle.php | 1 - src/Util/AbstractServiceSubscriber.php | 26 ------------------------- src/Util/ContainerUtil.php | 8 +++----- src/Util/RoutingUtil.php | 4 ---- src/Util/Utils.php | 16 +++------------ 7 files changed, 11 insertions(+), 56 deletions(-) delete mode 100644 src/Util/AbstractServiceSubscriber.php diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a16d100b..d790c9d2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -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 diff --git a/src/EventListener/DcaAuthorListener.php b/src/EventListener/DcaAuthorListener.php index bd5f0299..fd0d1bc4 100644 --- a/src/EventListener/DcaAuthorListener.php +++ b/src/EventListener/DcaAuthorListener.php @@ -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) { diff --git a/src/HeimrichHannotUtilsBundle.php b/src/HeimrichHannotUtilsBundle.php index 3ac78f27..9a7f082c 100644 --- a/src/HeimrichHannotUtilsBundle.php +++ b/src/HeimrichHannotUtilsBundle.php @@ -8,7 +8,6 @@ namespace HeimrichHannot\UtilsBundle; -use HeimrichHannot\UtilsBundle\DependencyInjection\HeimrichHannotUtilsExtension; use Symfony\Component\HttpKernel\Bundle\Bundle; class HeimrichHannotUtilsBundle extends Bundle diff --git a/src/Util/AbstractServiceSubscriber.php b/src/Util/AbstractServiceSubscriber.php deleted file mode 100644 index 9f9eeff0..00000000 --- a/src/Util/AbstractServiceSubscriber.php +++ /dev/null @@ -1,26 +0,0 @@ -framework->getAdapter(Input::class)->cookie('FE_PREVIEW'); } - public static function getSubscribedServices() + public static function getSubscribedServices(): array { return [ 'monolog.logger.contao' => LoggerInterface::class, diff --git a/src/Util/RoutingUtil.php b/src/Util/RoutingUtil.php index dbf1a7df..c05368a4 100644 --- a/src/Util/RoutingUtil.php +++ b/src/Util/RoutingUtil.php @@ -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, diff --git a/src/Util/Utils.php b/src/Util/Utils.php index 91734443..a93c7571 100644 --- a/src/Util/Utils.php +++ b/src/Util/Utils.php @@ -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 @@ -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,