diff --git a/composer.json b/composer.json index da0f141..131cac6 100644 --- a/composer.json +++ b/composer.json @@ -25,8 +25,8 @@ "require":{ "ext-json": "*", "php": "^7.4 || ^8.0", - "contao/core-bundle": "^4.9", - "symfony/http-client": "^4.4 || ^5.4" + "contao/core-bundle": "^4.13 || ^5.1", + "symfony/http-client": "^4.4 || ^5.4 || ^6.0" }, "extra": { "contao-manager-plugin": "Plenta\\ContaoTinyCompressImages\\ContaoManager\\Plugin" diff --git a/src/Plenta/ContaoTinyCompressImages/ContaoManager/Plugin.php b/src/Plenta/ContaoTinyCompressImages/ContaoManager/Plugin.php index 433ca86..1dbce5f 100644 --- a/src/Plenta/ContaoTinyCompressImages/ContaoManager/Plugin.php +++ b/src/Plenta/ContaoTinyCompressImages/ContaoManager/Plugin.php @@ -3,7 +3,7 @@ declare(strict_types=1); /** - * @copyright Copyright (c) 2015-2021, Plenta.io & Christian Barkowsky + * @copyright Copyright (c) 2015-2023, Plenta.io & Christian Barkowsky * @author Christian Barkowsky * @package tiny-compress-images * @license LGPL @@ -17,14 +17,8 @@ use Contao\ManagerPlugin\Bundle\Parser\ParserInterface; use Plenta\ContaoTinyCompressImages\PlentaContaoTinyCompressImagesBundle; -/** - * Class ContaoManagerPlugin. - */ class Plugin implements BundlePluginInterface { - /** - * {@inheritdoc} - */ public function getBundles(ParserInterface $parser): array { return [ diff --git a/src/Plenta/ContaoTinyCompressImages/Resources/contao/config/config.php b/src/Plenta/ContaoTinyCompressImages/Resources/contao/config/config.php index c8f87a1..d0f66c9 100644 --- a/src/Plenta/ContaoTinyCompressImages/Resources/contao/config/config.php +++ b/src/Plenta/ContaoTinyCompressImages/Resources/contao/config/config.php @@ -3,12 +3,20 @@ declare(strict_types=1); /** - * @copyright Copyright (c) 2015-2021, Plenta.io & Christian Barkowsky + * @copyright Copyright (c) 2015-2023, Plenta.io & Christian Barkowsky * @author David Greminger * @package tiny-compress-images * @license LGPL */ -$GLOBALS['BE_MOD']['system']['files'] = array_merge($GLOBALS['BE_MOD']['system']['files'], [ - 'tinify' => ['plenta.contao_tiny_compress_images.listener.data_container', 'onCompress'] -]); +use Contao\CoreBundle\ContaoCoreBundle; + +if (version_compare(ContaoCoreBundle::getVersion(), '5.0', '>=')) { + $GLOBALS['BE_MOD']['content']['files'] = array_merge($GLOBALS['BE_MOD']['content']['files'], [ + 'tinify' => ['plenta.contao_tiny_compress_images.listener.data_container', 'onCompress'] + ]); +} else { + $GLOBALS['BE_MOD']['system']['files'] = array_merge($GLOBALS['BE_MOD']['system']['files'], [ + 'tinify' => ['plenta.contao_tiny_compress_images.listener.data_container', 'onCompress'] + ]); +} diff --git a/src/Plenta/ContaoTinyCompressImages/TinyPNG/Compressor.php b/src/Plenta/ContaoTinyCompressImages/TinyPNG/Compressor.php index d88f7b4..e73c24c 100644 --- a/src/Plenta/ContaoTinyCompressImages/TinyPNG/Compressor.php +++ b/src/Plenta/ContaoTinyCompressImages/TinyPNG/Compressor.php @@ -3,7 +3,7 @@ declare(strict_types=1); /** - * @copyright Copyright (c) 2015-2022, Plenta.io & Christian Barkowsky + * @copyright Copyright (c) 2015-2023, Plenta.io & Christian Barkowsky * @author Christian Barkowsky * @author David Greminger * @package tiny-compress-images @@ -13,14 +13,15 @@ namespace Plenta\ContaoTinyCompressImages\TinyPNG; use Contao\Config; -use Contao\CoreBundle\Framework\ContaoFramework; -use Contao\CoreBundle\Monolog\ContaoContext; -use Contao\FilesModel; use Contao\Message; +use Contao\FilesModel; use Psr\Log\LoggerInterface; -use Symfony\Contracts\HttpClient\Exception\ExceptionInterface; +use Contao\CoreBundle\ContaoCoreBundle; +use Contao\CoreBundle\Monolog\ContaoContext; +use Contao\CoreBundle\Framework\ContaoFramework; use Symfony\Contracts\HttpClient\HttpClientInterface; use Symfony\Contracts\Translation\TranslatorInterface; +use Symfony\Contracts\HttpClient\Exception\ExceptionInterface; class Compressor { @@ -85,7 +86,8 @@ public function compress(string $filename): ?FilesModel return null; } - if (version_compare(VERSION, '4.13', '>=')) { + //if (version_compare(VERSION, '4.13', '>=')) { + if (version_compare(ContaoCoreBundle::getVersion(), '4.13', '>=')) { $filePath = \Symfony\Component\Filesystem\Path::join($this->projectDir, $file->path); } else { $filePath = \Webmozart\PathUtil\Path::join($this->projectDir, $file->path);