source: sandbox/expresso-solr/expressoMail1_2/solrclient/library/Solarium/Plugin/CustomizeRequest/Customization.php @ 7588

Revision 7588, 5.1 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 */
37
38/**
39 * Customization value object
40 *
41 * @package Solarium
42 * @subpackage Plugin
43 */
44class Solarium_Plugin_CustomizeRequest_Customization extends Solarium_Configurable
45{
46
47    /**
48     * Type definition for params
49     */
50    const TYPE_PARAM = 'param';
51
52    /**
53     * Type definition for headers
54     */
55    const TYPE_HEADER = 'header';
56
57    /**
58     * Default options
59     *
60     * @var array
61     */
62    protected $_options = array(
63        'key' => null,
64        'type' => null,
65        'name' => null,
66        'value' => null,
67        'persistent' => false,
68        'overwrite' => true,
69    );
70
71    /**
72     * Set key value
73     *
74     * @param string $value
75     * @return Solarium_Plugin_CustomizeRequest_Customization
76     */
77    public function setKey($value)
78    {
79        $this->_setOption('key', $value);
80        return $this;
81    }
82
83    /**
84     * Get key value
85     *
86     * @return string
87     */
88    public function getKey()
89    {
90        return $this->getOption('key');
91    }
92
93    /**
94     * Set type value
95     *
96     * @param string $value
97     * @return Solarium_Plugin_CustomizeRequest_Customization
98     */
99    public function setType($value)
100    {
101        $this->_setOption('type', $value);
102        return $this;
103    }
104
105    /**
106     * Get type value
107     *
108     * @return string
109     */
110    public function getType()
111    {
112        return $this->getOption('type');
113    }
114
115    /**
116     * Set name value
117     *
118     * @param string $value
119     * @return Solarium_Plugin_CustomizeRequest_Customization
120     */
121    public function setName($value)
122    {
123        $this->_setOption('name', $value);
124        return $this;
125    }
126
127    /**
128     * Get name value
129     *
130     * @return string
131     */
132    public function getName()
133    {
134        return $this->getOption('name');
135    }
136
137    /**
138     * Set value
139     *
140     * @param string $value
141     * @return Solarium_Plugin_CustomizeRequest_Customization
142     */
143    public function setValue($value)
144    {
145        $this->_setOption('value', $value);
146        return $this;
147    }
148
149    /**
150     * Get value
151     *
152     * @return string
153     */
154    public function getValue()
155    {
156        return $this->getOption('value');
157    }
158
159    /**
160     * Set persistent on/off
161     *
162     * @param boolean $value
163     * @return Solarium_Plugin_CustomizeRequest_Customization
164     */
165    public function setPersistent($value)
166    {
167        $this->_setOption('persistent', $value);
168        return $this;
169    }
170
171    /**
172     * Get persistent setting
173     *
174     * @return boolean
175     */
176    public function getPersistent()
177    {
178        return $this->getOption('persistent');
179    }
180
181    /**
182     * Set overwrite option on/off
183     *
184     * @param boolean $value
185     * @return Solarium_Plugin_CustomizeRequest_Customization
186     */
187    public function setOverwrite($value)
188    {
189        $this->_setOption('overwrite', $value);
190        return $this;
191    }
192
193    /**
194     * Get overwrite option value
195     *
196     * @return boolean
197     */
198    public function getOverwrite()
199    {
200        return $this->getOption('overwrite');
201    }
202
203    /**
204     * Check for all mandatory settings
205     *
206     * @return bool
207     */
208    public function isValid()
209    {
210        $type = $this->getType();
211        if ($type !== self::TYPE_PARAM && $type !== self::TYPE_HEADER) return false;
212
213        if (null == $this->getKey() || null == $this->getName() || null == $this->getValue()) return false;
214
215        return true;
216    }
217
218}
Note: See TracBrowser for help on using the repository browser.