source: sandbox/expresso-solr/expressoMail1_2/inc/solrclient/library/Solarium/Query/Update/Command/Delete.php @ 7576

Revision 7576, 4.5 KB checked in by adir, 11 years ago (diff)

Ticket #000 - Adicionando a integracao de buscas com Solr na base a ser isnerida na comunidade

Line 
1<?php
2/**
3 * Copyright 2011 Bas de Nooijer. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice,
9 *    this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright notice,
12 *    this listof conditions and the following disclaimer in the documentation
13 *    and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS"
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
26 *
27 * The views and conclusions contained in the software and documentation are
28 * those of the authors and should not be interpreted as representing official
29 * policies, either expressed or implied, of the copyright holder.
30 *
31 * @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
32 * @license http://github.com/basdenooijer/solarium/raw/master/COPYING
33 * @link http://www.solarium-project.org/
34 *
35 * @package Solarium
36 * @subpackage Query
37 */
38
39/**
40 * Update query delete command
41 *
42 * For details about the Solr options see:
43 * @link http://wiki.apache.org/solr/UpdateXmlMessages#A.22delete.22_by_ID_and_by_Query
44 *
45 * @package Solarium
46 * @subpackage Query
47 */
48class Solarium_Query_Update_Command_Delete extends Solarium_Query_Update_Command
49{
50
51    /**
52     * Ids to delete
53     *
54     * @var array
55     */
56    protected $_ids = array();
57
58    /**
59     * Delete queries
60     *
61     * @var array
62     */
63    protected $_queries = array();
64
65    /**
66     * Get command type
67     *
68     * @return string
69     */
70    public function getType()
71    {
72        return Solarium_Query_Update::COMMAND_DELETE;
73    }
74
75    /**
76     * Build ids/queries based on options
77     *
78     * @return void
79     */
80    protected function _init()
81    {
82        $id = $this->getOption('id');
83        if (null !== $id) {
84            if (is_array($id)) {
85                $this->addIds($id);
86            } else {
87                $this->addId($id);
88            }
89        }
90       
91        $queries = $this->getOption('query');
92        if (null !== $queries) {
93            if (is_array($queries)) {
94                $this->addQueries($queries);
95            } else {
96                $this->addQuery($queries);
97            }
98        }
99    }
100
101    /**
102     * Add a single ID to the delete command
103     *
104     * @param int|string $id
105     * @return Solarium_Query_Update_Command_Delete Provides fluent interface
106     */
107    public function addId($id)
108    {
109        $this->_ids[] = $id;
110
111        return $this;
112    }
113
114    /**
115     * Add multiple IDs to the delete command
116     *
117     * @param array $ids
118     * @return Solarium_Query_Update_Command_Delete Provides fluent interface
119     */
120    public function addIds($ids)
121    {
122        $this->_ids = array_merge($this->_ids, $ids);
123
124        return $this;
125    }
126
127    /**
128     * Add a single query to the delete command
129     *
130     * @param string $query
131     * @return Solarium_Query_Update_Command_Delete Provides fluent interface
132     */
133    public function addQuery($query)
134    {
135        $this->_queries[] = $query;
136
137        return $this;
138    }
139
140    /**
141     * Add multiple queries to the delete command
142     *
143     * @param array $queries
144     * @return Solarium_Query_Update_Command_Delete Provides fluent interface
145     */
146    public function addQueries($queries)
147    {
148        $this->_queries = array_merge($this->_queries, $queries);
149
150        return $this;
151    }
152
153    /**
154     * Get all queries of this delete command
155     *
156     * @return array
157     */
158    public function getQueries()
159    {
160        return $this->_queries;
161    }
162
163    /**
164     * Get all qids of this delete command
165     *
166     * @return array
167     */
168    public function getIds()
169    {
170        return $this->_ids;
171    }
172
173}
Note: See TracBrowser for help on using the repository browser.