Completed
Push — master ( 07b37d...b10e41 )
by Torben
02:00
created

EditRecordViewHelper   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 2
c 1
b 1
f 0
lcom 0
cbo 1
dl 0
loc 28
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A render() 0 17 2
1
<?php
2
namespace DERHANSEN\SfEventMgt\ViewHelpers\Be;
3
4
/*
5
 * This file is part of the TYPO3 CMS project.
6
 *
7
 * It is free software; you can redistribute it and/or modify it under
8
 * the terms of the GNU General Public License, either version 2
9
 * of the License, or any later version.
10
 *
11
 * For the full copyright and license information, please read the
12
 * LICENSE.txt file that was distributed with this source code.
13
 *
14
 * The TYPO3 project - inspiring people to share!
15
 */
16
17
use TYPO3\CMS\Backend\Utility\BackendUtility;
18
use TYPO3\CMS\Core\Utility\GeneralUtility;
19
20
/**
21
 * ViewHelper for a backend link that should edit the given event UID
22
 *
23
 * @author Torben Hansen <[email protected]>
24
 */
25
class EditRecordViewHelper extends AbstractRecordViewHelper
26
{
27
    /**
28
     * Renders a edit link for the given Event UID
29
     *
30
     * @todo: Remove condition, when TYPO3 6.2 is deprecated
31
     *
32
     * @param int $uid
33
     * @return string
34
     */
35
    public function render($uid)
36
    {
37
        $pid = (int)GeneralUtility::_GET('id');
38
39
        if (GeneralUtility::compat_version('7.6')) {
40
            $parameters = [
41
                'edit[tx_sfeventmgt_domain_model_event][' . (int)$uid . ']' => 'edit',
42
            ];
43
            $parameters['returnUrl'] = 'index.php?M=web_SfEventMgtTxSfeventmgtM1&id=' . $pid . $this->getModuleToken();
44
            $url = BackendUtility::getModuleUrl('record_edit', $parameters);
45
        } else {
46
            $returnUrl = 'mod.php?M=web_SfEventMgtTxSfeventmgtM1&id=' . $pid . $this->getModuleToken();
47
            $url = 'alt_doc.php?edit[tx_sfeventmgt_domain_model_event][' . (int)$uid .
48
                ']=edit&returnUrl=' . urlencode($returnUrl);
49
        }
50
        return $url;
51
    }
52
}
53