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

Markdown::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 4
dl 0
loc 5
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