Skip to content

Commit

Permalink
Move functions for InkyExtension
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Dec 9, 2023
1 parent 034c17d commit 5cae5be
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
13 changes: 8 additions & 5 deletions extra/inky-extra/InkyExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,15 @@ class InkyExtension extends AbstractExtension
public function getFilters()
{
return [
new TwigFilter('inky_to_html', 'Twig\\Extra\\Inky\\twig_inky', ['is_safe' => ['html']]),
new TwigFilter('inky_to_html', [self::class, 'inky'], ['is_safe' => ['html']]),
];
}
}

function twig_inky(string $body): string
{
return false === ($html = Pinky\transformString($body)->saveHTML()) ? '' : $html;
/**
* @internal
*/
public static function inky(string $body): string
{
return false === ($html = Pinky\transformString($body)->saveHTML()) ? '' : $html;
}
}
23 changes: 23 additions & 0 deletions extra/inky-extra/Resources/functions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Twig\Extra\Inky;

/**
* @internal
* @deprecated since Twig 3.9.0
*/
function twig_inky(string $body): string
{
trigger_deprecation('twig/inky-extra', '3.9.0', 'Using the internal "%s" function is deprecated.', __FUNCTION__);

return InkyExtension::inky($body);
}
2 changes: 2 additions & 0 deletions extra/inky-extra/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@
],
"require": {
"php": ">=7.2.5",
"symfony/deprecation-contracts": "^2.5|^3",
"lorenzo/pinky": "^1.0.5",
"twig/twig": "^3.0"
},
"require-dev": {
"symfony/phpunit-bridge": "^6.4|^7.0"
},
"autoload": {
"files": [ "Resources/functions.php" ],
"psr-4" : { "Twig\\Extra\\Inky\\" : "" },
"exclude-from-classmap": [
"/Tests/"
Expand Down

0 comments on commit 5cae5be

Please sign in to comment.