Completed
Push — master ( ee9c7d...9819c1 )
by Rafael
14:45
created

AbstractResultParser::canParse()

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 1
c 0
b 0
f 0
nc 1
1
<?php
2
3
namespace ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Result\Parser;
4
5
/***************************************************************
6
 *  Copyright notice
7
 *
8
 *  (c) 2015-2017 Timo Hund <[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\Domain\Search\ResultSet\Result\SearchResultBuilder;
29
use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Result\SearchResultCollection;
30
use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\SearchResultSet;
31
use ApacheSolrForTypo3\Solr\System\Configuration\TypoScriptConfiguration;
32
use TYPO3\CMS\Core\Utility\GeneralUtility;
33
34
/**
35
 * A ResultParser is responsible to create the result object structure from the \Apache_Solr_Response
36
 * and assign it to the SearchResultSet.
37
 *
38
 * @package ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Result\Parser
39
 */
40
abstract class AbstractResultParser {
41
42
    /**
43
     * @var SearchResultBuilder
44
     */
45
    protected $searchResultBuilder;
46
47
    /**
48
     * @var TypoScriptConfiguration
49
     */
50
    protected $typoScriptConfiguration;
51
52
    /**
53
     * @var DocumentEscapeService
54
     */
55
    protected $documentEscapeService;
56
57
    /**
58
     * AbstractResultParser constructor.
59
     * @param TypoScriptConfiguration|null $typoScriptConfiguration
60
     * @param SearchResultBuilder|null $resultBuilder
61
     * @param DocumentEscapeService|null $documentEscapeService
62
     */
63
    public function __construct(TypoScriptConfiguration $typoScriptConfiguration = null,
64
                                SearchResultBuilder $resultBuilder = null,
65
                                DocumentEscapeService $documentEscapeService = null) {
66
        $this->typoScriptConfiguration = $typoScriptConfiguration;
67
        $this->searchResultBuilder = is_null($resultBuilder) ? GeneralUtility::makeInstance(SearchResultBuilder::class) : $resultBuilder;
68
        $this->documentEscapeService = is_null($documentEscapeService) ? GeneralUtility::makeInstance(DocumentEscapeService::class, $typoScriptConfiguration) : $documentEscapeService;
69
    }
70
71
    /**
72
     * @param SearchResultSet $resultSet
73
     * @param bool $useRawDocuments
74
     * @return SearchResultCollection
75
     */
76
    abstract public function parse(SearchResultSet $resultSet, bool $useRawDocuments = true);
77
78
    /**
79
     * @param SearchResultSet $resultSet
80
     * @return mixed
81
     */
82
    abstract public function canParse(SearchResultSet $resultSet);
83
}