Completed
Push — development ( ef0625...f79737 )
by Torben
04:11
created

AbstractRecordViewHelper::isV9up()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
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\Routing\UriBuilder;
12
use TYPO3\CMS\Backend\Utility\BackendUtility;
13
use TYPO3\CMS\Core\Utility\GeneralUtility;
14
use TYPO3\CMS\Core\Utility\VersionNumberUtility;
15
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
16
17
/**
18
 * Abstract Record viewhelper for backend links
19
 *
20
 * @author Torben Hansen <[email protected]>
21
 */
22
abstract class AbstractRecordViewHelper extends AbstractViewHelper
23
{
24
    public function getReturnUrl() : string
25
    {
26
        return GeneralUtility::getIndpEnv('REQUEST_URI');
27
    }
28
29
    /**
30
     * Returns the full module URL for the given parameters depending on the current TYPO3 version
31
     *
32
     * @param array $parameters
33
     * @return string
34
     * @throws \TYPO3\CMS\Backend\Routing\Exception\RouteNotFoundException
35
     */
36
    public function getModuleUrl($parameters)
37
    {
38
        if ($this->isV9up()) {
39
            $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
40
            $uri = (string)$uriBuilder->buildUriFromRoute('record_edit', $parameters);
41
        } else {
42
            $uri = BackendUtility::getModuleUrl('record_edit', $parameters);
0 ignored issues
show
Deprecated Code introduced by
The method TYPO3\CMS\Backend\Utilit...Utility::getModuleUrl() has been deprecated with message: since TYPO3 v9, will be removed in TYPO3 v10.0. Use UriBuilder instead.

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
43
        }
44
        return $uri;
45
    }
46
47
    /**
48
     * @return bool
49
     */
50
    private function isV9up(): bool
51
    {
52
        return VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version) >= 9000000;
53
    }
54
}
55