Skip to content

Commit

Permalink
#32
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Barkowsky committed Sep 15, 2023
1 parent df0e3ea commit e28e181
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 19 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 1 addition & 7 deletions src/Plenta/ContaoTinyCompressImages/ContaoManager/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>
* @package tiny-compress-images
* @license LGPL
Expand All @@ -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 [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://github.com/bytehead>
* @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']
]);
}
14 changes: 8 additions & 6 deletions src/Plenta/ContaoTinyCompressImages/TinyPNG/Compressor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://github.com/plenta>
* @author David Greminger <https://github.com/bytehead>
* @package tiny-compress-images
Expand All @@ -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
{
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit e28e181

Please sign in to comment.