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

PropertyViewHelper::render()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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