1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ApacheSolrForTypo3\Solr\ViewHelpers\Format; |
4
|
|
|
|
5
|
|
|
/*************************************************************** |
6
|
|
|
* Copyright notice |
7
|
|
|
* |
8
|
|
|
* (c) 2013-2015 Ingo Renner <[email protected]> |
9
|
|
|
* All rights reserved |
10
|
|
|
* |
11
|
|
|
* This script is part of the TYPO3 project. The TYPO3 project is |
12
|
|
|
* free software; you can redistribute it and/or modify |
13
|
|
|
* it under the terms of the GNU General Public License as published by |
14
|
|
|
* the Free Software Foundation; either version 2 of the License, or |
15
|
|
|
* (at your option) any later version. |
16
|
|
|
* |
17
|
|
|
* The GNU General Public License can be found at |
18
|
|
|
* http://www.gnu.org/copyleft/gpl.html. |
19
|
|
|
* |
20
|
|
|
* This script is distributed in the hope that it will be useful, |
21
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
22
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
23
|
|
|
* GNU General Public License for more details. |
24
|
|
|
* |
25
|
|
|
* This copyright notice MUST APPEAR in all copies of the script! |
26
|
|
|
***************************************************************/ |
27
|
|
|
|
28
|
|
|
use ApacheSolrForTypo3\Solr\ViewHelpers\AbstractSolrViewHelper; |
29
|
|
|
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface; |
30
|
|
|
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* ViewHelper to implode an array with a specific glue value. |
34
|
|
|
* |
35
|
|
|
* @author Timo Hund <[email protected]> |
36
|
|
|
*/ |
37
|
|
|
class ImplodeViewHelper extends AbstractSolrViewHelper |
38
|
|
|
{ |
39
|
|
|
use CompileWithRenderStatic; |
40
|
|
|
|
41
|
|
|
// Set $escapeOutput to false in order to ensure that "newline" is handled correctly |
42
|
|
|
protected $escapeOutput = false; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Initializes the arguments |
46
|
|
|
*/ |
47
|
|
|
public function initializeArguments() |
48
|
|
|
{ |
49
|
|
|
parent::initializeArguments(); |
50
|
|
|
$this->registerArgument('glue', 'string', 'The glue value', false, ','); |
51
|
|
|
$this->registerArgument('value', 'array', 'The the array to implode', false, []); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @param array $arguments |
56
|
|
|
* @param \Closure $renderChildrenClosure |
57
|
|
|
* @param RenderingContextInterface $renderingContext |
58
|
|
|
* @return string |
59
|
|
|
*/ |
60
|
1 |
|
public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) |
61
|
|
|
{ |
62
|
1 |
|
$glue = isset($arguments['glue']) ? $arguments['glue'] : ','; |
63
|
1 |
|
$value = isset($arguments['value']) ? $arguments['value'] : []; |
64
|
|
|
|
65
|
1 |
|
return implode($glue, $value); |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
|