Completed
Pull Request — master (#281)
by
unknown
02:12
created

EditRecordViewHelper::initializeArguments()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/**
4
 * Edit Record ViewHelper, see FormEngine logic.
5
 */
6
declare(strict_types=1);
7
8
namespace HDNET\Calendarize\ViewHelpers;
9
10
use TYPO3\CMS\Backend\Utility\BackendUtility;
11
use TYPO3\CMS\Core\Utility\GeneralUtility;
12
13
/**
14
 * Edit Record ViewHelper, see FormEngine logic.
15
 *
16
 * @internal
17
 */
18
class EditRecordViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper
19
{
20
    /**
21
     * Init arguments.
22
     */
23
    public function initializeArguments()
24
    {
25
        parent::initializeArguments();
26
        $this->registerArgument('parameters', 'string', 'A set of GET params to send to FormEngine', true);
27
    }
28
29
30
    /**
31
     * Returns a URL to link to FormEngine.
32
     *
33
     * @return string URL to FormEngine module + parameters
34
     *
35
     * @see \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl()
36
     */
37
    public function render()
38
    {
39
        $parameters = $this->arguments['parameters'];
40
        $returnUrl = BackendUtility::getModuleUrl('web_CalendarizeCalendarize');
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...
41
        $parameters = GeneralUtility::explodeUrl2Array($parameters . '&returnUrl=' . \urlencode($returnUrl));
42
43
        return BackendUtility::getModuleUrl('record_edit', $parameters);
0 ignored issues
show
Bug introduced by
It seems like $parameters defined by \TYPO3\CMS\Core\Utility\...\urlencode($returnUrl)) on line 41 can also be of type null; however, TYPO3\CMS\Backend\Utilit...Utility::getModuleUrl() does only seem to accept array, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
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...
44
    }
45
}
46