KnpMarkdownBundle/Helper/MarkdownHelper.php
Ryan Weaver 91a268692e Making the templating component an optional dependency
It already basically was, but we were requiring it.
2018-01-22 20:45:26 -05:00

66 lines
1.5 KiB
PHP

<?php
namespace Knp\Bundle\MarkdownBundle\Helper;
use Knp\Bundle\MarkdownBundle\Parser\ParserManager;
use Symfony\Component\Templating\Helper\HelperInterface;
/**
* @deprecated The MarkdownHelper was deprecated in 1.7 and will be removed in 2.0.
*/
class MarkdownHelper implements HelperInterface
{
private $parserManager;
private $charset = 'UTF-8';
public function __construct(ParserManager $parserManager)
{
$this->parserManager = $parserManager;
}
/**
* Transforms markdown syntax to HTML
*
* @param string $markdownText The markdown syntax text
* @param null|string $parserName
*
* @return string The HTML code
*
* @throws \RuntimeException
*/
public function transform($markdownText, $parserName = null)
{
trigger_error('The MarkdownHelper was deprecated in 1.7 and will be removed in KnpMarkdownBundle 2.0.', E_USER_DEPRECATED);
return $this->parserManager->transform($markdownText, $parserName);
}
/**
* Sets the default charset.
*
* @param string $charset The charset
*/
public function setCharset($charset)
{
$this->charset = $charset;
}
/**
* Gets the default charset.
*
* @return string The default charset
*/
public function getCharset()
{
return $this->charset;
}
/**
* {@inheritDoc}
*/
public function getName()
{
return 'markdown';
}
}