Passed
Push — master ( 203e1d...831cab )
by Timo
27:25
created

RemoveFacetViewHelper   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 41.67%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 27
ccs 5
cts 12
cp 0.4167
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A initializeArguments() 0 5 1
A renderStatic() 0 8 1
1
<?php
2
namespace ApacheSolrForTypo3\Solr\ViewHelpers\Uri\Facet;
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\Facets\AbstractFacet;
18
use ApacheSolrForTypo3\Solr\ViewHelpers\Uri\AbstractUriViewHelper;
19
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
20
21
/**
22
 * Class FacetAddOptionViewHelper
23
 *
24
 * @author Frans Saris <[email protected]>
25
 * @author Timo Hund <[email protected]>
26
 * @package ApacheSolrForTypo3\Solr\ViewHelpers\Link
27
 */
28
class RemoveFacetViewHelper extends AbstractUriViewHelper
29
{
30
    /**
31
     * Initializes the arguments
32
     */
33
    public function initializeArguments()
34
    {
35
        parent::initializeArguments();
36
        $this->registerArgument('facet', AbstractFacet::class, 'The facet', true);
37
    }
38
39
    /**
40
     * @param array $arguments
41
     * @param \Closure $renderChildrenClosure
42
     * @param RenderingContextInterface $renderingContext
43
     * @return string
44
     * @throws \InvalidArgumentException
45
     */
46 1
    public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
47
    {
48
        /** @var  $facet AbstractFacet */
49 1
        $facet = $arguments['facet'];
50 1
        $previousRequest = $facet->getResultSet()->getUsedSearchRequest();
51 1
        $uri = self::getSearchUriBuilder()->getRemoveFacetUri($previousRequest, $facet->getName());
52 1
        return $uri;
53
    }
54
}
55