XMLGoogleShoppingFeedController   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 9
dl 0
loc 30
rs 10
c 2
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getContentType() 0 3 1
A getExtension() 0 3 1
A SiteConfig() 0 3 1
A Items() 0 6 1
1
<?php
2
3
namespace Sunnysideup\EcommerceGoogleShoppingFeed\Controllers;
4
5
use SilverStripe\Core\Config\Config;
6
use SilverStripe\SiteConfig\SiteConfig;
7
8
/**
9
 * Controller for displaying the xml feed.
10
 *
11
 * <code>
12
 * http://site.com/shoppingfeed.xml
13
 * </code>
14
 *
15
 */
16
class XMLGoogleShoppingFeedController extends GoogleShoppingFeedController
17
{
18
    /**
19
     * @var array
20
     */
21
    private static $allowed_actions = [
22
        'index',
23
    ];
24
25
    public function SiteConfig()
26
    {
27
        return SiteConfig::current_site_config();
28
    }
29
30
    public function Items()
31
    {
32
        $apiClassName = Config::inst()->get(GoogleShoppingFeedController::class, 'api_class');
33
        $apiClass = new $apiClassName();
34
35
        return $apiClass->getArrayList();
36
    }
37
38
    protected function getExtension(): string
39
    {
40
        return 'xml';
41
    }
42
43
    protected function getContentType(): string
44
    {
45
        return 'application/xml; charset="utf-8"';
46
    }
47
}
48