PageControllerExtension   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 5
dl 0
loc 12
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A onAfterInit() 0 6 2
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
}