Completed
Push — development ( 60d679...69d31d )
by Torben
02:26
created

NewRecordViewHelper::render()   C

Complexity

Conditions 7
Paths 4

Size

Total Lines 24
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 24
rs 6.7272
c 1
b 0
f 0
cc 7
eloc 14
nc 4
nop 0
1
<?php
2
namespace DERHANSEN\SfEventMgt\ViewHelpers\Be;
3
4
/*
5
 * This file is part of the Extension "sf_event_mgt" for TYPO3 CMS.
6
 *
7
 * For the full copyright and license information, please read the
8
 * LICENSE.txt file that was distributed with this source code.
9
 */
10
11
use TYPO3\CMS\Backend\Utility\BackendUtility;
12
use TYPO3\CMS\Core\Utility\GeneralUtility;
13
14
/**
15
 * ViewHelper for a backend link that generates a new Event
16
 *
17
 * @author Torben Hansen <[email protected]>
18
 */
19
class NewRecordViewHelper extends AbstractRecordViewHelper
20
{
21
    /**
22
     * Renders a new record link
23
     *
24
     * @return string
25
     */
26
    public function render()
27
    {
28
        $pid = (int)GeneralUtility::_GET('id');
29
30
        if ($pid === 0) {
31
            $tsConfig = BackendUtility::getPagesTSconfig(0);
32
            if (isset($tsConfig['tx_sfeventmgt.']['module.']) && is_array($tsConfig['tx_sfeventmgt.']['module.'])) {
33
                $tsConfiguration = $tsConfig['tx_sfeventmgt.']['module.'];
34
                if (isset($tsConfiguration['defaultPid.'])
35
                    && is_array($tsConfiguration['defaultPid.'])
36
                    && isset($tsConfiguration['defaultPid.']['tx_sfeventmgt_domain_model_event'])
37
                ) {
38
                    $pid = (int)$tsConfiguration['defaultPid.']['tx_sfeventmgt_domain_model_event'];
39
                }
40
            }
41
        }
42
43
        $parameters = [
44
            'edit[tx_sfeventmgt_domain_model_event][' . $pid . ']' => 'new',
45
        ];
46
        $parameters['returnUrl'] = 'index.php?M=web_SfEventMgtTxSfeventmgtM1&id=' . $pid . $this->getModuleToken();
47
48
        return BackendUtility::getModuleUrl('record_edit', $parameters);
49
    }
50
}
51