mirror of
https://github.com/KnpLabs/KnpMarkdownBundle.git
synced 2024-06-10 09:52:19 +02:00
6dba9b29bc
Hello,
I just updated this file to be compatible with Symfony 5.
The twig filters and extensions were deprecated.
Cheers 😉
35 lines
759 B
PHP
35 lines
759 B
PHP
<?php
|
|
|
|
namespace Knp\Bundle\MarkdownBundle\Twig\Extension;
|
|
|
|
use Knp\Bundle\MarkdownBundle\Parser\ParserManager;
|
|
use Twig\Extension\AbstractExtension;
|
|
use Twig\TwigFilter;
|
|
|
|
class MarkdownTwigExtension extends AbstractExtension
|
|
{
|
|
private $parserManager;
|
|
|
|
public function __construct(ParserManager $parserManager)
|
|
{
|
|
$this->parserManager = $parserManager;
|
|
}
|
|
|
|
public function getFilters()
|
|
{
|
|
return array(
|
|
new TwigFilter('markdown', array($this, 'markdown'), array('is_safe' => array('html'))),
|
|
);
|
|
}
|
|
|
|
public function markdown($text, $parser = null)
|
|
{
|
|
return $this->parserManager->transform($text, $parser);
|
|
}
|
|
|
|
public function getName()
|
|
{
|
|
return 'markdown';
|
|
}
|
|
}
|