Passed
Push — master ( 22bc6e...3fff97 )
by Dev
13:34
created

Markdown::applyRendering()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
nc 2
nop 0
dl 0
loc 7
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace PiedWeb\CMSBundle\Service\PageMainContentManager;
4
5
use Knp\Bundle\MarkdownBundle\MarkdownParserInterface;
6
use PiedWeb\CMSBundle\Entity\PageInterface;
7
use PiedWeb\CMSBundle\Service\App;
8
use Twig\Environment as Twig;
9
10
class Markdown extends Raw
11
{
12
    protected $markdownParser;
13
14
    public function __construct(App $app, Twig $twig, PageInterface $page, MarkdownParserInterface $markdownParser)
15
    {
16
        $this->markdownParser = $markdownParser;
17
18
        parent::__construct($app, $twig, $page);
19
    }
20
21
    protected function applyRendering()
22
    {
23
        parent::applyRendering(); // always apply twig rendering before markdown, avoid some errors
24
25
        foreach ($this->parts as $part) {
26
            $this->$part = $this->convertMarkdownImage($this->$part);
27
            $this->$part = $this->markdownParser->transformMarkdown($this->$part);
28
        }
29
    }
30
}
31