1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Class BackendController |
5
|
|
|
*/ |
6
|
|
|
|
7
|
|
|
namespace HDNET\OnpageIntegration\Controller; |
8
|
|
|
|
9
|
|
|
use HDNET\OnpageIntegration\Exception\UnavailableAccessDataException; |
10
|
|
|
use HDNET\OnpageIntegration\Utility\ArrayUtility; |
11
|
|
|
use HDNET\OnpageIntegration\Utility\TitleUtility; |
12
|
|
|
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Class BackendController |
16
|
|
|
*/ |
17
|
|
|
class BackendController extends ActionController |
18
|
|
|
{ |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @var \HDNET\OnpageIntegration\Loader\ApiResultLoader |
22
|
|
|
* @inject |
23
|
|
|
*/ |
24
|
|
|
protected $loader; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @var \HDNET\OnpageIntegration\Provider\MetaDataProvider |
28
|
|
|
* @inject |
29
|
|
|
*/ |
30
|
|
|
protected $metaDataProvider; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @var \HDNET\OnpageIntegration\Domain\Repository\ConfigurationRepository |
34
|
|
|
* @inject |
35
|
|
|
*/ |
36
|
|
|
protected $configurationRepository; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Represent the index page |
40
|
|
|
*/ |
41
|
|
|
public function indexAction() |
42
|
|
|
{ |
43
|
|
|
try { |
44
|
|
|
$seoMetaData[] = $this->metaDataProvider->getMetaData('seoaspects'); |
|
|
|
|
45
|
|
|
$contentMetaData[] = $this->metaDataProvider->getMetaData('contentaspects'); |
|
|
|
|
46
|
|
|
$technicalMetaData[] = $this->metaDataProvider->getMetaData('technicalaspects'); |
|
|
|
|
47
|
|
|
|
48
|
|
|
ArrayUtility::buildIndexActionArray($seoMetaData, 'seoaspects'); |
49
|
|
|
ArrayUtility::buildIndexActionArray($technicalMetaData, 'technicalaspects'); |
50
|
|
|
ArrayUtility::buildIndexActionArray($contentMetaData, 'contentaspects'); |
51
|
|
|
|
52
|
|
|
|
53
|
|
|
$this->view->assignMultiple([ |
54
|
|
|
'lastCrawl' => $this->loader->load('zoom_lastcrawl'), |
55
|
|
|
'seoMetaData' => $seoMetaData, |
56
|
|
|
'contentMetaData' => $contentMetaData, |
57
|
|
|
'technicalMetaData' => $technicalMetaData, |
58
|
|
|
'moduleName' => 'Zoom Module' |
59
|
|
|
]); |
60
|
|
|
} catch (UnavailableAccessDataException $e) { |
61
|
|
|
return "Bitte tragen Sie Ihre Zugangsdaten ein."; |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Handle the detail pages |
67
|
|
|
* |
68
|
|
|
* @param string $section |
69
|
|
|
* @param string $call |
70
|
|
|
*/ |
71
|
|
|
public function detailAction($section, $call) |
72
|
|
|
{ |
73
|
|
|
/** @var \HDNET\OnpageIntegration\Domain\Model\Configuration $configuration */ |
74
|
|
|
$configuration = $this->configurationRepository->findRecord(1); |
75
|
|
|
|
76
|
|
|
$metaDataProvider = $this->metaDataProvider->getMetaData($section); |
77
|
|
|
|
78
|
|
|
$showTableKey = $metaDataProvider[$call]['show']; |
|
|
|
|
79
|
|
|
$apiCallTable = 'zoom_' . $section . '_' . $call . '_table'; |
80
|
|
|
|
81
|
|
|
$table = $this->loader->load($apiCallTable); |
82
|
|
|
#$table = ArrayUtility::showTable($this->loader->load($apiCallTable), $showTableKey); |
|
|
|
|
83
|
|
|
|
84
|
|
|
$this->view->assignMultiple([ |
85
|
|
|
'moduleName' => TitleUtility::makeSubTitle($section), |
86
|
|
|
'configuration' => $configuration, |
87
|
|
|
'table' => $table, |
88
|
|
|
]); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* Empty Keyword Page |
93
|
|
|
*/ |
94
|
|
|
public function keywordAction() |
95
|
|
|
{ |
96
|
|
|
$this->view->assignMultiple([ |
97
|
|
|
'moduleName' => 'Keyword' |
98
|
|
|
]); |
99
|
|
|
} |
100
|
|
|
} |
101
|
|
|
|
Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.
Let’s take a look at an example:
As you can see in this example, the array
$myArray
is initialized the first time when the foreach loop is entered. You can also see that the value of thebar
key is only written conditionally; thus, its value might result from a previous iteration.This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.