CmsLayout::renderConfigurationTable()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
3
/**
4
 * CmsLayout
5
 */
6
7
namespace FRUIT\GoogleServices\Hooks;
8
9
use TYPO3\CMS\Core\Utility\GeneralUtility;
10
11
/**
12
 * CmsLayout
13
 */
14
class CmsLayout
15
{
16
17
    /**
18
     * render sitemap plugin information
19
     *
20
     * @param array $params
21
     * @param object $object
22
     *
23
     * @return string
24
     */
25
    public function renderSitemapPlugin($params, $object)
0 ignored issues
show
Unused Code introduced by
The parameter $object is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
26
    {
27
        $xml = $params['row']['pi_flexform'];
28
        $data = GeneralUtility::xml2array($xml);
29
30
        if (!isset($data['data'])) {
31
            return '[no Configuration]';
32
        }
33
34
        if (!isset($data['data']['sDEF'])) {
35
            return '[no Configuration]';
36
        }
37
38
        if (!isset($data['data']['sDEF']['lDEF'])) {
39
            return '[no Configuration]';
40
        }
41
42
        $configurationData = $data['data']['sDEF']['lDEF'];
43
44
        $configuration = [
45
            'Action' => implode(';', $configurationData['switchableControllerActions']),
46
            'Provider' => implode(';', $configurationData['settings.provider']),
47
            'StartPoint' => implode(';', $configurationData['settings.startpoint']),
48
            'Depth' => implode(';', $configurationData['settings.depth']),
49
        ];
50
51
        return $this->renderConfigurationTable($configuration);
52
    }
53
54
    /**
55
     * Render the configuration table
56
     *
57
     * @param $elements
58
     *
59
     * @return string
60
     */
61
    protected function renderConfigurationTable($elements)
62
    {
63
        $table = '<table>';
64
        foreach ($elements as $key => $value) {
65
            $table .= '<tr><td><b>' . $key . ': </b></td><td>' . $value . '</td></tr>';
66
        }
67
        return $table . '</table>';
68
    }
69
}
70