diff --git a/composer.json b/composer.json index e59b519..73d1c47 100755 --- a/composer.json +++ b/composer.json @@ -9,7 +9,7 @@ "nette/di": "^3.0", "nette/http": "^3.1", "nette/schema": "^1.0", - "nette/utils": "^3.2", + "nette/utils": "^3.2 || ^4.0", "imagine/imagine": "^1.2.3" }, "require-dev": { @@ -29,8 +29,8 @@ "psr-4": { "Nelson\\Resizer\\Tests\\": "tests/" } }, "scripts": { - "phpstan": "./phpstan/phpstan", - "tests": "./vendor/bin/phpunit --configuration tests/phpunit.xml tests" + "phpstan": "@php ./vendor/bin/phpstan analyse --configuration ./phpstan/phpstan.neon --memory-limit 512M", + "tests": "@php ./vendor/bin/phpunit --configuration tests/phpunit.xml tests" }, "config": { "allow-plugins": { diff --git a/phpstan/phpstan b/phpstan/phpstan deleted file mode 100755 index 9e146d0..0000000 --- a/phpstan/phpstan +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -./vendor/bin/phpstan analyse --configuration ./phpstan/phpstan.neon diff --git a/src/DI/ResizerExtension.php b/src/DI/ResizerExtension.php index 193a867..2fef1cb 100755 --- a/src/DI/ResizerExtension.php +++ b/src/DI/ResizerExtension.php @@ -55,13 +55,8 @@ public function beforeCompile(): void $latteFactoryDef = $this->getLatteFactoryDefinition(); $latteFactoryDef->addSetup('addFilter', ['resize', [$this->prefix('@default'), 'resize']]); - if (version_compare(Engine::VERSION, '3', '<')) { - // Latte 2.x - $latteFactoryDef->addSetup('Nelson\Resizer\Latte\Macros::install(?->getCompiler())', ['@self']); - } else { - // Latte 3.x - $latteFactoryDef->addSetup('addExtension', [new LatteResizerExtension]); - } + // Latte 3.x + $latteFactoryDef->addSetup('addExtension', [new LatteResizerExtension]); // Presenter mappings $mapping = [self::PRESENTER_MAPPING => '\Nelson\Resizer\Presenters\*Presenter']; diff --git a/src/Latte/Macros.php b/src/Latte/Macros.php deleted file mode 100644 index 2b5b241..0000000 --- a/src/Latte/Macros.php +++ /dev/null @@ -1,50 +0,0 @@ -addMacro('rlink', [$me, 'macroResizer']); - } - - - public function macroResizer(MacroNode $node, PhpWriter $writer): string - { - $absolute = substr($node->args, 0, 2) === '//' ? '"//" . ' : ''; - $args = $absolute ? substr($node->args, 2) : $node->args; - return $writer->using($node, $this->getCompiler()) - ->write( - '$lg = $presenter ?? $this->global->uiControl;' - . 'echo %escape(%modify(' - . '$lg' - . '->link(' - . $absolute - . 'Nelson\Resizer\Latte\Macros::getLink($lg),' - . self::prepareArgs($args) - . ')))', - ); - } - - - public static function getLink(object $class): string - { - return ResizerExtension::getResizerLink(!($class instanceof LinkGenerator)); - } - - - public static function prepareArgs(string $args): string - { - return '[' . $args . ']'; - } -}