Making the templating component an optional dependency

It already basically was, but we were requiring it.
This commit is contained in:
Ryan Weaver 2018-01-22 20:43:42 -05:00
parent 77d1412005
commit 91a268692e
4 changed files with 18 additions and 3 deletions

6
CHANGELOG.md Normal file
View File

@ -0,0 +1,6 @@
1.7
===
* The MarkdownHelper Templating component integration (and corresponding
`templating.helper.markdown` services) are no longer added unless you
have the `symfony/templating` component installed.

View File

@ -10,6 +10,7 @@ use Symfony\Component\DependencyInjection\Alias;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\Templating\EngineInterface;
class KnpMarkdownExtension extends Extension
{
@ -29,7 +30,10 @@ class KnpMarkdownExtension extends Extension
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('parser.xml');
$loader->load('helper.xml');
// BC to support the PHP templates in the Templating component
if (interface_exists(EngineInterface::class)) {
$loader->load('helper.xml');
}
$loader->load('twig.xml');
if ('markdown.parser.sundown' == $config['parser']['service']) {

View File

@ -5,6 +5,9 @@ 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;
@ -27,6 +30,8 @@ class MarkdownHelper implements HelperInterface
*/
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);
}

View File

@ -21,11 +21,11 @@
"php": ">=5.5.9",
"symfony/framework-bundle": "~2.8|~3.0|^4.0",
"symfony/dependency-injection": "~2.8|~3.0|^4.0",
"symfony/templating": "~2.8|~3.0|^4.0",
"michelf/php-markdown": "~1.4"
},
"require-dev": {
"phpunit/phpunit": "~4.5"
"phpunit/phpunit": "~4.5",
"symfony/templating": "~2.8|~3.0|^4.0"
},
"suggest": {
"symfony/twig-bundle": "to use the Twig markdown filter",