Completed
Push — master ( e11c40...a2b9d1 )
by WEBEWEB
12:30
created

AbstractModalTwigExtension::getTypography()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the adminbsb-material-design-bundle package.
5
 *
6
 * (c) 2018 WEBEWEB
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace WBW\Bundle\AdminBSBBundle\Twig\Extension\UI;
13
14
use Twig_Environment;
15
use WBW\Bundle\AdminBSBBundle\Twig\Extension\AbstractTwigExtension;
16
use WBW\Bundle\AdminBSBBundle\Twig\Extension\RendererTwigExtension;
17
use WBW\Bundle\BootstrapBundle\Twig\Extension\CSS\TypographyTwigExtension;
18
use WBW\Bundle\BootstrapBundle\Twig\Extension\CSS\TypographyTwigExtensionTrait;
19
20
/**
21
 * Abstract modal Twig extension.
22
 *
23
 * @author webeweb <https://github.com/webeweb/>
24
 * @package WBW\Bundle\AdminBSBBundle\Twig\Extension\UI
25
 * @abstract
26
 */
27
abstract class AbstractModalTwigExtension extends AbstractTwigExtension {
28
29
    use TypographyTwigExtensionTrait;
30
31
    /**
32
     * Constructor.
33
     *
34
     * @param Twig_Environment $twigEnvironment The Twig environment.
35
     * @param TypographyTwigExtension $typographyTwigExtension The typography.
36
     */
37
    protected function __construct(Twig_Environment $twigEnvironment, TypographyTwigExtension $typographyTwigExtension) {
38
        parent::__construct($twigEnvironment);
39
        $this->setTypographyTwigExtension($typographyTwigExtension);
40
    }
41
42
    /**
43
     * Displays an AdminBSB modal header.
44
     *
45
     * @param string $content The content.
46
     * @param string $icon The icon.
47
     * @return string Returns the AdminBSB modal header.
48
     */
49
    protected function adminBSBModalHeader($content, $icon) {
50
51
        // Initialize the parameters.
52
        $innerHTML = $content;
53
        if (null !== $icon) {
54
            $innerHTML = RendererTwigExtension::renderIcon($this->getTwigEnvironment(), $icon, "margin: -4px 0; vertical-align: sub;") . $innerHTML;
55
        }
56
57
        // Return the HTML.
58
        return $this->getTypographyTwigExtension()->bootstrapHeading3Function(["class" => "modal-title", "content" => $innerHTML]);
59
    }
60
}
61