mirror of
https://github.com/twigphp/Twig.git
synced 2026-08-31 12:37:15 +00:00
Move functions for InkyExtension
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* 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);
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Twig.
|
||||
*
|
||||
* (c) Fabien Potencier
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Twig\Extra\Inky\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Twig\Extra\Inky\InkyExtension;
|
||||
use function Twig\Extra\Inky\twig_inky;
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
class LegacyFunctionsTest extends TestCase
|
||||
{
|
||||
public function testInlineCss()
|
||||
{
|
||||
$this->assertSame(InkyExtension::inky('<p>Foo</p>'), twig_inky('<p>Foo</p>'));
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@
|
||||
],
|
||||
"require": {
|
||||
"php": ">=7.2.5",
|
||||
"symfony/deprecation-contracts": "^2.5|^3",
|
||||
"lorenzo/pinky": "^1.0.5",
|
||||
"twig/twig": "^3.0"
|
||||
},
|
||||
@@ -23,6 +24,7 @@
|
||||
"symfony/phpunit-bridge": "^6.4|^7.0"
|
||||
},
|
||||
"autoload": {
|
||||
"files": [ "Resources/functions.php" ],
|
||||
"psr-4" : { "Twig\\Extra\\Inky\\" : "" },
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
|
||||
Reference in New Issue
Block a user