1
<?php
2

3
/*
4
 * This file is part of the Solarium package.
5
 *
6
 * For the full copyright and license information, please view the COPYING
7
 * file that was distributed with this source code.
8
 */
9

10
namespace Solarium\QueryType\Stream;
11

12
use Solarium\Core\Client\Client;
13
use Solarium\Core\Query\AbstractQuery;
14
use Solarium\Core\Query\RequestBuilderInterface;
15
use Solarium\Core\Query\ResponseParserInterface;
16
use Solarium\QueryType\Select\Result\Document;
17

18
/**
19
 * Stream query.
20
 */
21
class Query extends AbstractQuery
22
{
23
    /**
24
     * Default options.
25
     *
26
     * @var array
27
     */
28
    protected $options = [
29
        'handler' => 'stream',
30
        'resultclass' => Result::class,
31
        'documentclass' => Document::class,
32
    ];
33

34
    /**
35
     * Get type for this query.
36
     *
37
     * @return string
38
     */
39 0
    public function getType(): string
40
    {
41 0
        return Client::QUERY_STREAM;
42
    }
43

44
    /**
45
     * Get a requestbuilder for this query.
46
     *
47
     * @return RequestBuilder
48
     */
49 0
    public function getRequestBuilder(): RequestBuilderInterface
50
    {
51 0
        return new RequestBuilder();
52
    }
53

54
    /**
55
     * Get a response parser for this query.
56
     *
57
     * @return ResponseParser
58
     */
59 0
    public function getResponseParser(): ResponseParserInterface
60
    {
61 0
        return new ResponseParser();
62
    }
63

64
    /**
65
     * Set the expression.
66
     *
67
     * @param string $expr
68
     *
69
     * @return self Provides fluent interface
70
     */
71 12
    public function setExpression(string $expr): self
72
    {
73 12
        $this->setOption('expr', $expr);
74

75 12
        return $this;
76
    }
77

78
    /**
79
     * Get the expression.
80
     *
81
     * @return string|null
82
     */
83 12
    public function getExpression(): ?string
84
    {
85 12
        return $this->getOption('expr');
86
    }
87

88
    /**
89
     * Set a custom document class.
90
     *
91
     * This class should implement the document interface
92
     *
93
     * @param string $value classname
94
     *
95
     * @return self Provides fluent interface
96
     */
97 0
    public function setDocumentClass(string $value): self
98
    {
99 0
        $this->setOption('documentclass', $value);
100

101 0
        return $this;
102
    }
103

104
    /**
105
     * Get the current documentclass option.
106
     *
107
     * The value is a classname, not an instance
108
     *
109
     * @return string|null
110
     */
111 0
    public function getDocumentClass(): ?string
112
    {
113 0
        return $this->getOption('documentclass');
114
    }
115
}

Read our documentation on viewing source code .

Loading