From 68518f2f057c133048bddacd18873ee86c6b5a28 Mon Sep 17 00:00:00 2001 From: Andreas Schempp Date: Tue, 27 Aug 2024 11:08:07 +0200 Subject: [PATCH] Restore compatibility with Haste 4 --- composer.json | 2 +- src/EventListener/DataContainerListener.php | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index ff72835..a113d8a 100755 --- a/composer.json +++ b/composer.json @@ -27,7 +27,7 @@ "require": { "php": "^8.0", "contao/core-bundle": "^4.13 || ^5.0", - "codefog/contao-haste": "^5.0", + "codefog/contao-haste": "^4.21 || ^5.0", "codefog/tags-bundle": "^3.3", "doctrine/dbal": "^3.3", "psr/log": "^1.0 || ^2.0 || ^3.0", diff --git a/src/EventListener/DataContainerListener.php b/src/EventListener/DataContainerListener.php index ff7b4a5..34832a4 100755 --- a/src/EventListener/DataContainerListener.php +++ b/src/EventListener/DataContainerListener.php @@ -21,6 +21,7 @@ use Contao\System; use Contao\Validator; use Doctrine\DBAL\Connection; +use Haste\Model\Model; use Psr\Log\LoggerInterface; use Psr\Log\LogLevel; use Symfony\Component\HttpFoundation\RequestStack; @@ -182,7 +183,12 @@ public function onLabelCallback(array $row, string $label, DataContainer|null $d } $tags = []; - $tagIds = DcaRelationsModel::getRelatedValues('tl_node', 'tags', $row['id']); + + if (\class_exists(DcaRelationsModel::class)) { + $tagIds = DcaRelationsModel::getRelatedValues('tl_node', 'tags', $row['id']); + } else { + $tagIds = Model::getRelatedValues('tl_node', 'tags', $row['id']); + } // Generate the tags if (\count($tagIds) > 0) {