Completed
Push — master ( 305f48...ad447f )
by Fabien
02:33
created

PropertyViewHelper   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 25
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A initializeArguments() 0 4 1
A render() 0 8 1
1
<?php
2
namespace Fab\Media\ViewHelpers\File;
3
4
/*
5
 * This file is part of the Fab/Media project under GPLv2 or later.
6
 *
7
 * For the full copyright and license information, please read the
8
 * LICENSE.md file that was distributed with this source code.
9
 */
10
11
use TYPO3\CMS\Core\Resource\File;
12
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
13
14
/**
15
 * View helper which returns property value of a file given by the context.
16
 */
17
class PropertyViewHelper extends AbstractViewHelper
18
{
19
20
    /**
21
     * @return void
22
     */
23
    public function initializeArguments()
24
    {
25
        $this->registerArgument('name', 'string', '', true);
26
    }
27
28
    /**
29
     * Returns a property value of a file given by the context.
30
     *
31
     * @return string
32
     */
33
    public function render()
34
    {
35
        $name = $this->arguments['name'];
36
37
        /** @var File $file */
38
        $file = $this->templateVariableContainer->get('file');
39
        return $file->getProperty($name);
40
    }
41
}
42