Passed
Push — master ( a4d2df...1b8200 )
by Timo
25:26 queued 24:42
created

AbstractOptionsFacet::getPartialName()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 2
eloc 2
nc 2
nop 0
1
<?php
2
namespace ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Facets\OptionBased;
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\Domain\Search\ResultSet\SearchResultSet;
19
20
/**
21
 * Class QueryGroupFacet
22
 *
23
 * @author Frans Saris <[email protected]>
24
 * @author Timo Hund <[email protected]>
25
 * @package ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Facets\QueryGroupFacet
26
 */
27
class AbstractOptionsFacet extends AbstractFacet
28
{
29
30
    /**
31
     * @var OptionCollection
32
     */
33
    protected $options;
34
35
    /**
36
     * OptionsFacet constructor
37
     *
38
     * @param SearchResultSet $resultSet
39
     * @param string $name
40
     * @param string $field
41
     * @param string $label
42
     * @param array $configuration Facet configuration passed from typoscript
43
     */
44
    public function __construct(SearchResultSet $resultSet, $name, $field, $label = '', array $configuration = [])
45
    {
46
        parent::__construct($resultSet, $name, $field, $label, $configuration);
47
        $this->options = new OptionCollection();
48
    }
49
50
    /**
51
     * @return OptionCollection
52
     */
53
    public function getOptions()
54
    {
55
        return $this->options;
56
    }
57
58
    /**
59
     * @param OptionCollection $options
60
     */
61
    public function setOptions($options)
62
    {
63
        $this->options = $options;
64
    }
65
66
    /**
67
     * @param AbstractOptionFacetItem $option
68
     */
69
    public function addOption(AbstractOptionFacetItem $option)
70
    {
71
        $this->options->add($option);
72
    }
73
74
    /**
75
     * The implementation of this method should return a "flatten" collection of all items.
76
     *
77
     * @return OptionCollection
78
     */
79
    public function getAllFacetItems()
80
    {
81
        return $this->options;
82
    }
83
84
    /**
85
     * Get facet partial name used for rendering the facet
86
     *
87
     * @return string
88
     */
89
    public function getPartialName()
90
    {
91
        return !empty($this->configuration['partialName']) ? $this->configuration['partialName'] : 'Options';
92
    }
93
}
94