Completed
Push — master ( 9819c1...f2d6e9 )
by Rafael
06:19
created

GroupItemPageViewHelper::renderStatic()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 3
1
<?php
2
namespace ApacheSolrForTypo3\Solr\ViewHelpers\Uri\Paginate;
3
4
/*
5
 * This file is part of the TYPO3 CMS project.
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 2
9
 * of the License, or any later version.
10
 *
11
 * For the full copyright and license information, please read the
12
 * LICENSE.txt file that was distributed with this source code.
13
 *
14
 * The TYPO3 project - inspiring people to share!
15
 */
16
17
use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Grouping\GroupItem;
18
use ApacheSolrForTypo3\Solr\ViewHelpers\Uri\AbstractUriViewHelper;
19
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
20
21
/**
22
 * Class GroupItemPageViewHelper
23
 *
24
 * @author Frans Saris <[email protected]>
25
 * @author Timo Hund <[email protected]>
26
 * @package ApacheSolrForTypo3\Solr\ViewHelpers\Link
27
 */
28
class GroupItemPageViewHelper extends AbstractUriViewHelper
29
{
30
31
    /**
32
     * Initializes the arguments
33
     */
34
    public function initializeArguments()
35
    {
36
        parent::initializeArguments();
37
        $this->registerArgument('page', 'int', 'The page', false, 0);
38
        $this->registerArgument('groupItem', GroupItem::class, 'The group item', true);
39
40
    }
41
42
    /**
43
     * @param array $arguments
44
     * @param \Closure $renderChildrenClosure
45
     * @param RenderingContextInterface $renderingContext
46
     * @return string
47
     */
48
    public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
49
    {
50
        $page = $arguments['page'];
51
        $groupItem = $arguments['groupItem'];
52
        $previousRequest = static::getUsedSearchRequestFromRenderingContext($renderingContext);
53
        $uri = self::getSearchUriBuilder()->getResultGroupItemPageUri($previousRequest, $groupItem, (int)$page);
54
        return $uri;
55
    }
56
}
57