Passed
Push — master ( dfdc20...741bbb )
by Aske
04:09
created

AssetExistsViewHelper::render()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 1
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
1
<?php
2
namespace AE\History\ViewHelpers;
3
4
/*                                                                        *
5
 * This script belongs to the TYPO3 Flow package "TYPO3.Neos".            *
6
 *                                                                        *
7
 * It is free software; you can redistribute it and/or modify it under    *
8
 * the terms of the GNU General Public License, either version 3 of the   *
9
 * License, or (at your option) any later version.                        *
10
 *                                                                        *
11
 * The TYPO3 project - inspiring people to share!                         *
12
 *                                                                        */
13
14
use Doctrine\ORM\EntityNotFoundException;
15
use TYPO3\Flow\Annotations as Flow;
16
use TYPO3\Fluid\Core\ViewHelper\AbstractViewHelper;
17
use TYPO3\Media\Domain\Model\AssetInterface;
18
19
/**
20
 *
21
 */
22
class AssetExistsViewHelper extends AbstractViewHelper
23
{
24
25
    /**
26
     * @var boolean
27
     */
28
    protected $escapeOutput = false;
29
30
    /**
31
     * Checks if an asset exists.
32
     *
33
     * @param AssetInterface $asset
34
     * @return string
35
     */
36
    public function render(AssetInterface $asset)
37
    {
38
        try {
39
            $asset->getResource();
40
        } catch(EntityNotFoundException $e) {
41
            return '';
42
        }
43
        return $this->renderChildren();
44
    }
45
}
46