PageControllerExtension::onAfterInit()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
<?php
2
3
namespace DorsetDigital\TawkTo;
4
5
use SilverStripe\Core\Extension;
6
use SilverStripe\SiteConfig\SiteConfig;
7
use SilverStripe\View\Requirements;
8
9
class PageControllerExtension extends Extension
10
{
11
    /**
12
     * Add the script to the end of the page if it's in the config
13
     * We remove any tags here, since they shouldn't be in the snippet
14
     */
15
    public function onAfterInit()
16
    {
17
        $config = SiteConfig::current_site_config();
18
        if ($config->TawkToEmbedCode != "") {
19
            $embed = strip_tags($config->TawkToEmbedCode);
20
            Requirements::customScript($embed);
21
        }
22
    }
23
}