Completed
Pull Request — master (#470)
by Claus
01:34
created

ParameterViewHelper::initializeArguments()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 9
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 9
loc 9
rs 9.9666
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
namespace TYPO3Fluid\Fluid\ViewHelpers;
4
5
/*
6
 * This file belongs to the package "TYPO3 Fluid".
7
 * See LICENSE.txt that was shipped with this package.
8
 */
9
10
use TYPO3Fluid\Fluid\Component\EmbeddedComponentInterface;
11
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
12
13
/**
14
 * Parameter Declaration ViewHelper
15
 *
16
 * Declares one parameter for a template file or section,
17
 * depending on where the ViewHelper is used. The declared
18
 * argument must then be present when the template file
19
 * or section is rendered, or a parsing error will be thrown.
20
 *
21
 * Note that this ViewHelper and f:argument differ in
22
 * functionality in very important ways:
23
 *
24
 * - f:argument allows you to pass "arguments" which is normally
25
 *   an array, as separate tags for an easier to use syntax.
26
 * - whereas f:parameter is used to declare such an argument
27
 *   much like using $this->registerArgument in a VieWHelper
28
 *   registers a supported argument.
29
 *
30
 * The former is used to PASS ARGUMENTS. The latter is used
31
 * to DECLARE ARGUMENTS THAT CAN/MUST BE PASSED.
32
 */
33
class ParameterViewHelper extends AbstractViewHelper implements EmbeddedComponentInterface
34
{
35
    protected $escapeOutput = false;
36
37
    /**
38
     * @return void
39
     */
40 View Code Duplication
    public function initializeArguments()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
41
    {
42
        parent::initializeArguments();
43
        $this->registerArgument('name', 'string', 'Name of the parameter', true);
44
        $this->registerArgument('type', 'string', 'Data type of the parameter, e.g. string/int/bool', true);
45
        $this->registerArgument('description', 'string', 'Brief description of parameter. For increased detail you can use this ViewHelper in tag mode and add f:description inside the tag');
46
        $this->registerArgument('required', 'bool', 'If TRUE, becomes required parameter that causes errors if not provided', false, false);
47
        $this->registerArgument('default', 'mixed', 'Default value of the parameter if not required and not passed');
48
    }
49
}
50