Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
S
solarium
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
common
solarium
Commits
bb7dc32e
Commit
bb7dc32e
authored
Mar 23, 2012
by
Bas de Nooijer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added interfaces (issue #50), also some fixes in unittests
parent
19813a82
Changes
34
Hide whitespace changes
Inline
Side-by-side
Showing
34 changed files
with
653 additions
and
108 deletions
+653
-108
library/Solarium/Core/Client/Adapter/AdapterInterface.php
library/Solarium/Core/Client/Adapter/AdapterInterface.php
+6
-10
library/Solarium/Core/Client/Adapter/Curl.php
library/Solarium/Core/Client/Adapter/Curl.php
+2
-1
library/Solarium/Core/Client/Adapter/Http.php
library/Solarium/Core/Client/Adapter/Http.php
+2
-1
library/Solarium/Core/Client/Adapter/PeclHttp.php
library/Solarium/Core/Client/Adapter/PeclHttp.php
+2
-1
library/Solarium/Core/Client/Adapter/ZendHttp.php
library/Solarium/Core/Client/Adapter/ZendHttp.php
+2
-1
library/Solarium/Core/Client/Client.php
library/Solarium/Core/Client/Client.php
+47
-30
library/Solarium/Core/Configurable.php
library/Solarium/Core/Configurable.php
+1
-1
library/Solarium/Core/ConfigurableInterface.php
library/Solarium/Core/ConfigurableInterface.php
+103
-0
library/Solarium/Core/Plugin.php
library/Solarium/Core/Plugin.php
+2
-2
library/Solarium/Core/PluginInterface.php
library/Solarium/Core/PluginInterface.php
+157
-0
library/Solarium/Core/Query/Query.php
library/Solarium/Core/Query/Query.php
+1
-23
library/Solarium/Core/Query/QueryInterface.php
library/Solarium/Core/Query/QueryInterface.php
+140
-0
library/Solarium/Core/Query/RequestBuilder.php
library/Solarium/Core/Query/RequestBuilder.php
+3
-2
library/Solarium/Core/Query/RequestBuilderInterface.php
library/Solarium/Core/Query/RequestBuilderInterface.php
+63
-0
library/Solarium/Core/Query/ResponseParserInterface.php
library/Solarium/Core/Query/ResponseParserInterface.php
+4
-9
library/Solarium/Core/Query/Result/QueryType.php
library/Solarium/Core/Query/Result/QueryType.php
+2
-1
library/Solarium/Core/Query/Result/Result.php
library/Solarium/Core/Query/Result/Result.php
+1
-1
library/Solarium/Core/Query/Result/ResultInterface.php
library/Solarium/Core/Query/Result/ResultInterface.php
+80
-0
library/Solarium/Query/Analysis/RequestBuilder/Document.php
library/Solarium/Query/Analysis/RequestBuilder/Document.php
+2
-1
library/Solarium/Query/Analysis/RequestBuilder/Field.php
library/Solarium/Query/Analysis/RequestBuilder/Field.php
+3
-1
library/Solarium/Query/Analysis/RequestBuilder/RequestBuilder.php
...Solarium/Query/Analysis/RequestBuilder/RequestBuilder.php
+2
-1
library/Solarium/Query/Analysis/ResponseParser/Field.php
library/Solarium/Query/Analysis/ResponseParser/Field.php
+3
-3
library/Solarium/Query/MoreLikeThis/RequestBuilder.php
library/Solarium/Query/MoreLikeThis/RequestBuilder.php
+2
-1
library/Solarium/Query/Ping/RequestBuilder.php
library/Solarium/Query/Ping/RequestBuilder.php
+2
-1
library/Solarium/Query/Select/RequestBuilder/RequestBuilder.php
...y/Solarium/Query/Select/RequestBuilder/RequestBuilder.php
+2
-1
library/Solarium/Query/Select/ResponseParser/ResponseParser.php
...y/Solarium/Query/Select/ResponseParser/ResponseParser.php
+2
-2
library/Solarium/Query/Suggester/RequestBuilder.php
library/Solarium/Query/Suggester/RequestBuilder.php
+2
-1
library/Solarium/Query/Suggester/ResponseParser.php
library/Solarium/Query/Suggester/ResponseParser.php
+2
-2
library/Solarium/Query/Terms/RequestBuilder.php
library/Solarium/Query/Terms/RequestBuilder.php
+2
-1
library/Solarium/Query/Terms/ResponseParser.php
library/Solarium/Query/Terms/ResponseParser.php
+2
-2
library/Solarium/Query/Update/RequestBuilder.php
library/Solarium/Query/Update/RequestBuilder.php
+2
-1
library/Solarium/Query/Update/ResponseParser.php
library/Solarium/Query/Update/ResponseParser.php
+2
-2
tests/Solarium/Tests/Core/Client/ClientTest.php
tests/Solarium/Tests/Core/Client/ClientTest.php
+4
-4
tests/Solarium/Tests/Plugin/BufferedAddTest.php
tests/Solarium/Tests/Plugin/BufferedAddTest.php
+1
-1
No files found.
library/Solarium/Core/Client/Adapter/Adapter.php
→
library/Solarium/Core/Client/Adapter/Adapter
Interface
.php
View file @
bb7dc32e
...
...
@@ -40,13 +40,13 @@
* @namespace
*/
namespace
Solarium\Core\Client\Adapter
;
use
Solarium\Core\Configurable
;
use
Solarium\Core\Configurable
Interface
;
use
Solarium\Core\Client\Request
;
use
Solarium\Core\Client\Response
;
use
Solarium\Core\Client\Endpoint
;
/**
*
Base class for all
adapters
*
Interface for client
adapters
*
* The goal of an adapter is to accept a query, execute it and return the right
* result object. This is actually quite a complex task as it involves the
...
...
@@ -55,28 +55,24 @@ use Solarium\Core\Client\Endpoint;
* The adapter structure allows for varying implementations of this task.
*
* Most adapters will use some sort of HTTP client. In that case the
* Solarium\Client\Request request builders and Solarium\Client\Response
* response parsers can be used to simplify HTTP communication.
* See {@link Solarium\Client\Adapter\Http} as an example.
* query request builders and query response parsers can be used to simplify
* HTTP communication.
*
* However an adapter may also implement all logic by itself if needed.
*
* @package Solarium
* @subpackage Core
*/
abstract
class
Adapter
extends
Configurabl
e
interface
AdapterInterface
extends
ConfigurableInterfac
e
{
/**
* Execute a request
*
* Abstract method to require an implementation inside all adapters.
*
* @abstract
* @param Request $request
* @param Endpoint $endpoint
* @return Response
*/
abstract
public
function
execute
(
$request
,
$endpoint
);
function
execute
(
$request
,
$endpoint
);
}
\ No newline at end of file
library/Solarium/Core/Client/Adapter/Curl.php
View file @
bb7dc32e
...
...
@@ -40,6 +40,7 @@
* @namespace
*/
namespace
Solarium\Core\Client\Adapter
;
use
Solarium\Core\Configurable
;
use
Solarium\Core\Exception
;
use
Solarium\Core\Client\HttpException
;
use
Solarium\Core\Client\Request
;
...
...
@@ -53,7 +54,7 @@ use Solarium\Core\Client\Endpoint;
* @package Solarium
* @subpackage Core
*/
class
Curl
extends
Adapter
class
Curl
extends
Configurable
implements
AdapterInterface
{
/**
...
...
library/Solarium/Core/Client/Adapter/Http.php
View file @
bb7dc32e
...
...
@@ -40,6 +40,7 @@
* @namespace
*/
namespace
Solarium\Core\Client\Adapter
;
use
Solarium\Core\Configurable
;
use
Solarium\Core\Exception
;
use
Solarium\Core\Client\HttpException
;
use
Solarium\Core\Client\Request
;
...
...
@@ -52,7 +53,7 @@ use Solarium\Core\Client\Endpoint;
* @package Solarium
* @subpackage Core
*/
class
Http
extends
Adapter
class
Http
extends
Configurable
implements
AdapterInterface
{
/**
...
...
library/Solarium/Core/Client/Adapter/PeclHttp.php
View file @
bb7dc32e
...
...
@@ -41,6 +41,7 @@
* @namespace
*/
namespace
Solarium\Core\Client\Adapter
;
use
Solarium\Core\Configurable
;
use
Solarium\Core\Exception
;
use
Solarium\Core\Client\HttpException
;
use
Solarium\Core\Client\Request
;
...
...
@@ -54,7 +55,7 @@ use Solarium\Core\Client\Endpoint;
* @package Solarium
* @subpackage Core
*/
class
PeclHttp
extends
Adapter
class
PeclHttp
extends
Configurable
implements
AdapterInterface
{
/**
...
...
library/Solarium/Core/Client/Adapter/ZendHttp.php
View file @
bb7dc32e
...
...
@@ -41,6 +41,7 @@
*/
namespace
Solarium\Core\Client\Adapter
;
use
Solarium\Core\Configurable
;
use
Solarium\Core\Client
;
use
Solarium\Core\Client\Request
;
use
Solarium\Core\Client\Response
;
...
...
@@ -58,7 +59,7 @@ use Solarium\Core\Client\Endpoint;
* @package Solarium
* @subpackage Core
*/
class
ZendHttp
extends
Adapter
class
ZendHttp
extends
Configurable
implements
AdapterInterface
{
/**
...
...
library/Solarium/Core/Client/Client.php
View file @
bb7dc32e
...
...
@@ -42,9 +42,11 @@
namespace
Solarium\Core\Client
;
use
Solarium\Core\Exception
;
use
Solarium\Core\Configurable
;
use
Solarium\Core\Plugin
;
use
Solarium\Core\Query\Query
;
use
Solarium\Core\Query\Result
;
use
Solarium\Core\PluginInterface
;
use
Solarium\Core\Query\QueryInterface
;
use
Solarium\Core\Query\Result\ResultInterface
;
use
Solarium\Core\Client\Adapter\AdapterInterface
;
use
Solarium\Core\Query\RequestBuilderInterface
;
/**
* Main interface for interaction with Solr
...
...
@@ -180,7 +182,7 @@ class Client extends Configurable
* on first use by {@link getAdapter()} based on the 'adapter' entry in
* {@link $options}. This option can be set using {@link setAdapter()}
*
* @var Adapter
\Adapter
* @var Adapter
Interface
*/
protected
$adapter
;
...
...
@@ -395,9 +397,7 @@ class Client extends Configurable
/**
* Set the adapter
*
* The adapter has to be a class that extends
* {@link Solarium\Client\Adapter}.
*
* The adapter has to be a class that implements the AdapterInterface
*
* If a string is passed it is assumed to be the classname and it will be
* instantiated on first use. This requires the availability of the class
...
...
@@ -409,7 +409,7 @@ class Client extends Configurable
* If an adapter instance is passed it will replace the current adapter
* immediately, bypassing the lazy loading.
*
* @param string|Adapter
\Adapter
$adapter
* @param string|Adapter
Interface
$adapter
* @return self Provides fluent interface
*/
public
function
setAdapter
(
$adapter
)
...
...
@@ -417,12 +417,14 @@ class Client extends Configurable
if
(
is_string
(
$adapter
))
{
$this
->
adapter
=
null
;
return
$this
->
setOption
(
'adapter'
,
$adapter
);
}
else
{
}
else
if
(
$adapter
instanceof
AdapterInterface
)
{
// forward options
$adapter
->
setOptions
(
$this
->
options
);
// overwrite existing adapter
$this
->
adapter
=
$adapter
;
return
$this
;
}
else
{
throw
new
Exception
(
'Invalid adapter input for setAdapter'
);
}
}
...
...
@@ -442,15 +444,22 @@ class Client extends Configurable
protected
function
createAdapter
()
{
$adapterClass
=
$this
->
getOption
(
'adapter'
);
$this
->
adapter
=
new
$adapterClass
;
$this
->
adapter
->
setOptions
(
$this
->
getOption
(
'adapteroptions'
));
$adapter
=
new
$adapterClass
;
// check interface
if
(
!
(
$adapter
instanceof
AdapterInterface
))
{
throw
new
Exception
(
'An adapter must implement the AdapterInterface'
);
}
$adapter
->
setOptions
(
$this
->
getOption
(
'adapteroptions'
));
$this
->
adapter
=
$adapter
;
}
/**
* Get the adapter instance
*
* If {@see $adapter} doesn't hold an instance a new one will be created by
* calling {@see
_
createAdapter()}
* calling {@see createAdapter()}
*
* @param boolean $autoload
* @return Adapter\Adapter
...
...
@@ -531,8 +540,8 @@ class Client extends Configurable
$plugin
=
new
$plugin
;
}
if
(
!
(
$plugin
instanceof
Plugin
))
{
throw
new
Exception
(
'All plugins must
extend Solarium\Core\Plugin
'
);
if
(
!
(
$plugin
instanceof
Plugin
Interface
))
{
throw
new
Exception
(
'All plugins must
implement the PluginInterface
'
);
}
$plugin
->
initPlugin
(
$this
,
$options
);
...
...
@@ -669,16 +678,16 @@ class Client extends Configurable
/**
* Creates a request based on a query instance
*
* @param Query $query
* @param Query
Interface
$query
* @return Request
*/
public
function
createRequest
(
$query
)
public
function
createRequest
(
QueryInterface
$query
)
{
$pluginResult
=
$this
->
callPlugins
(
'preCreateRequest'
,
array
(
$query
),
true
);
if
(
$pluginResult
!==
null
)
return
$pluginResult
;
$requestBuilder
=
$query
->
getRequestBuilder
();
if
(
!
$requestBuilder
)
{
if
(
!
$requestBuilder
||
!
(
$requestBuilder
instanceof
RequestBuilderInterface
)
)
{
throw
new
Exception
(
'No requestbuilder returned by querytype: '
.
$query
->
getType
());
}
...
...
@@ -692,11 +701,11 @@ class Client extends Configurable
/**
* Creates a result object
*
* @param Query $query
* @param Query
Interface
$query
* @param array Response $response
* @return Result
* @return Result
Interface
*/
public
function
createResult
(
$query
,
$response
)
public
function
createResult
(
QueryInterface
$query
,
$response
)
{
$pluginResult
=
$this
->
callPlugins
(
'preCreateResult'
,
array
(
$query
,
$response
),
true
);
if
(
$pluginResult
!==
null
)
return
$pluginResult
;
...
...
@@ -704,6 +713,10 @@ class Client extends Configurable
$resultClass
=
$query
->
getResultClass
();
$result
=
new
$resultClass
(
$this
,
$query
,
$response
);
if
(
!
(
$result
instanceof
ResultInterface
))
{
throw
new
Exception
(
'Result class must implement the ResultInterface'
);
}
$this
->
callPlugins
(
'postCreateResult'
,
array
(
$query
,
$response
,
$result
));
return
$result
;
...
...
@@ -712,11 +725,11 @@ class Client extends Configurable
/**
* Execute a query
*
* @param Query
* @param Query
Interface
* @param Endpoint|string|null
* @return Result
* @return Result
Interface
*/
public
function
execute
(
$query
,
$endpoint
=
null
)
public
function
execute
(
QueryInterface
$query
,
$endpoint
=
null
)
{
$pluginResult
=
$this
->
callPlugins
(
'preExecute'
,
array
(
$query
),
true
);
if
(
$pluginResult
!==
null
)
return
$pluginResult
;
...
...
@@ -775,7 +788,7 @@ class Client extends Configurable
* @param Endpoint|string|null
* @return Solarium\Query\Ping\Result
*/
public
function
ping
(
$query
,
$endpoint
=
null
)
public
function
ping
(
QueryInterface
$query
,
$endpoint
=
null
)
{
return
$this
->
execute
(
$query
,
$endpoint
);
}
...
...
@@ -801,7 +814,7 @@ class Client extends Configurable
* @param Endpoint|string|null
* @return Solarium\Query\Update\Result
*/
public
function
update
(
$query
,
$endpoint
=
null
)
public
function
update
(
QueryInterface
$query
,
$endpoint
=
null
)
{
return
$this
->
execute
(
$query
,
$endpoint
);
}
...
...
@@ -826,7 +839,7 @@ class Client extends Configurable
* @param Endpoint|string|null
* @return Solarium\Query\Result\Select\Result
*/
public
function
select
(
$query
,
$endpoint
=
null
)
public
function
select
(
QueryInterface
$query
,
$endpoint
=
null
)
{
return
$this
->
execute
(
$query
,
$endpoint
);
}
...
...
@@ -851,7 +864,7 @@ class Client extends Configurable
* @param Endpoint
* @return Solarium\Query\MoreLikeThis\Result
*/
public
function
moreLikeThis
(
$query
,
$endpoint
=
null
)
public
function
moreLikeThis
(
QueryInterface
$query
,
$endpoint
=
null
)
{
return
$this
->
execute
(
$query
,
$endpoint
);
}
...
...
@@ -866,7 +879,7 @@ class Client extends Configurable
* @param Endpoint
* @return Solarium\Query\Analysis\Result\Document|Solarium\Query\Analysis\Result\Field
*/
public
function
analyze
(
$query
,
$endpoint
=
null
)
public
function
analyze
(
QueryInterface
$query
,
$endpoint
=
null
)
{
return
$this
->
execute
(
$query
,
$endpoint
);
}
...
...
@@ -881,7 +894,7 @@ class Client extends Configurable
* @param Endpoint|string|null
* @return Solarium\Query\Terms\Result
*/
public
function
terms
(
$query
,
$endpoint
=
null
)
public
function
terms
(
QueryInterface
$query
,
$endpoint
=
null
)
{
return
$this
->
execute
(
$query
,
$endpoint
);
}
...
...
@@ -896,7 +909,7 @@ class Client extends Configurable
* @param Endpoint|string|null
* @return Solarium\Query\Suggester\Result
*/
public
function
suggester
(
$query
,
$endpoint
=
null
)
public
function
suggester
(
QueryInterface
$query
,
$endpoint
=
null
)
{
return
$this
->
execute
(
$query
,
$endpoint
);
}
...
...
@@ -922,6 +935,10 @@ class Client extends Configurable
$class
=
$this
->
queryTypes
[
$type
];
$query
=
new
$class
(
$options
);
if
(
!
(
$query
instanceof
QueryInterface
))
{
throw
new
Exception
(
'All query classes must implement the QueryInterface'
);
}
$this
->
callPlugins
(
'postCreateQuery'
,
array
(
$type
,
$options
,
$query
));
return
$query
;
...
...
library/Solarium/Core/Configurable.php
View file @
bb7dc32e
...
...
@@ -50,7 +50,7 @@ namespace Solarium\Core;
* @package Solarium
* @subpackage Plugin
*/
class
Configurable
class
Configurable
implements
ConfigurableInterface
{
/**
...
...
library/Solarium/Core/ConfigurableInterface.php
0 → 100644
View file @
bb7dc32e
<?php
/**
* Copyright 2011 Bas de Nooijer. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this listof conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are
* those of the authors and should not be interpreted as representing official
* policies, either expressed or implied, of the copyright holder.
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
*/
/**
* @namespace
*/
namespace
Solarium\Core
;
/**
* Interface for configurable classes
*
* All classes implementing this interface are configurable using the constructor or
* setOption calls. This is the base for many Solarium classes, providing a
* uniform interface for various models.
*
* @package Solarium
* @subpackage Plugin
*/
interface
ConfigurableInterface
{
/**
* Constructor
*
* If options are passed they will be merged with {@link $options} using
* the {@link setOptions()} method.
*
* After handling the options the {@link _init()} method is called.
*
* @throws Exception
* @param array|\Zend_Config $options
* @return void
*/
function
__construct
(
$options
=
null
);
/**
* Set options
*
* If $options is an object it will be converted into an array by called
* it's toArray method. This is compatible with the Zend_Config classes in
* Zend Framework, but can also easily be implemented in any other object.
*
* @throws Exception
* @param array|\Zend_Config $options
* @param boolean $overwrite True for overwriting existing options, false
* for merging (new values overwrite old ones if needed)
*
* @return void
*/
function
setOptions
(
$options
,
$overwrite
=
false
);
/**
* Get an option value by name
*
* If the option is empty or not set a NULL value will be returned.
*
* @param string $name
* @return mixed
*/
function
getOption
(
$name
);
/**
* Get all options
*
* @return array
*/
function
getOptions
();
}
\ No newline at end of file
library/Solarium/Core/Plugin.php
View file @
bb7dc32e
...
...
@@ -45,7 +45,7 @@ use Solarium\Core\Configurable;
use
Solarium\Core\Query\Query
;
use
Solarium\Core\Client\Request
;
use
Solarium\Core\Client\Response
;
use
Solarium\Core\Query\Result
;
use
Solarium\Core\Query\Result
\Result
;
/**
* Base class for plugins
...
...
@@ -53,7 +53,7 @@ use Solarium\Core\Query\Result;
* @package Solarium
* @subpackage Core
*/
abstract
class
Plugin
extends
Configurable
abstract
class
Plugin
extends
Configurable
implements
PluginInterface
{
/**
...
...
library/Solarium/Core/PluginInterface.php
0 → 100644
View file @
bb7dc32e
<?php
/**
* Copyright 2011 Bas de Nooijer. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this listof conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are
* those of the authors and should not be interpreted as representing official
* policies, either expressed or implied, of the copyright holder.
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Core
*/
/**
* @namespace
*/
namespace
Solarium\Core
;
use
Solarium\Core\Client\Client
;
use
Solarium\Core\Query\Query
;
use
Solarium\Core\Client\Request
;
use
Solarium\Core\Client\Response
;
use
Solarium\Core\Query\Result\Result
;
/**
* Interface for plugins
*
* @package Solarium
* @subpackage Core
*/
interface
PluginInterface
extends
ConfigurableInterface
{
/**
* Initialize
*
* This method is called when the plugin is registered to a client instance
*
* @param Client $client
* @param array $options
*/
function
initPlugin
(
$client
,
$options
);
/**
* preCreateRequest hook
*
* @param Query $query
* @return void|Request
*/
function
preCreateRequest
(
$query
);
/**
* postCreateRequest hook
*
* @param Query $query
* @param Request $request
* @return void
*/
function
postCreateRequest
(
$query
,
$request
);
/**
* preExecuteRequest hook
*
* @param Request $request
* @return void|Response
*/
function
preExecuteRequest
(
$request
);
/**
* postExecuteRequest hook
*
* @param Request $request
* @param Response $response
* @return void
*/
function
postExecuteRequest
(
$request
,
$response
);
/**
* preCreateResult hook
*
* @param Query $query
* @param Response $response
* @return void|Result
*/
function
preCreateResult
(
$query
,
$response
);
/**
* postCreateResult hook
*
* @param Query $query
* @param Response $response
* @param Result $result
* @return void
*/
function
postCreateResult
(
$query
,
$response
,
$result
);
/**
* preExecute hook
*
* @param Query $query
* @return void|Result
*/
function
preExecute
(
$query
);
/**
* postExecute hook
*
* @param Query $query
* @param Result $result
* @return void
*/
function
postExecute
(
$query
,
$result
);
/**
* preCreateQuery hook
*
* @param string $type
* @param mixed $options
* @return void|Query
*/
function
preCreateQuery
(
$type
,
$options
);
/**
* postCreateQuery hook
*
* @param string $type
* @param mixed $options
* @param Query
* @return void
*/
function
postCreateQuery
(
$type
,
$options
,
$query
);
}
\ No newline at end of file
library/Solarium/Core/Query/Query.php
View file @
bb7dc32e
...
...
@@ -49,7 +49,7 @@ use Solarium\Core\Configurable;
* @package Solarium
* @subpackage Core
*/
abstract
class
Query
extends
Configurable
abstract
class
Query
extends
Configurable
implements
QueryInterface
{
/**
...
...
@@ -66,28 +66,6 @@ abstract class Query extends Configurable
*/
protected
$params
=
array
();
/**
* Get type for this query
*
* @return string
*/
abstract
public
function
getType
();
/**
* Get the requestbuilder class for this query
*
* @return object
*/
abstract
public
function
getRequestBuilder
();
/**
* Get the response parser class for this query
*
* @return object
*/
abstract
public
function
getResponseParser
();
/**
* Set handler option
*
...
...
library/Solarium/Core/Query/QueryInterface.php
0 → 100644
View file @
bb7dc32e
<?php
/**
* Copyright 2011 Bas de Nooijer. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this listof conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are
* those of the authors and should not be interpreted as representing official
* policies, either expressed or implied, of the copyright holder.
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Query
*/
/**
* @namespace
*/
namespace
Solarium\Core\Query
;
use
Solarium\Core\Query\Helper
;
use
Solarium\Core\ConfigurableInterface
;
/**
* Query interface
*
* @package Solarium
* @subpackage Core
*/
interface
QueryInterface
extends
ConfigurableInterface
{
/**
* Get type for this query
*
* @return string
*/
function
getType
();
/**
* Get the requestbuilder class for this query
*
* @return object
*/
function
getRequestBuilder
();
/**
* Get the response parser class for this query
*
* @return ResponseParserInterface
*/
function
getResponseParser
();
/**
* Set handler option
*
* @param string $handler
* @return self Provides fluent interface
*/
function
setHandler
(
$handler
);
/**
* Get handler option
*
* @return string
*/
function
getHandler
();
/**
* Set resultclass option
*
* If you set a custom result class it must be available through autoloading
* or a manual require before calling this method. This is your
* responsibility.
*
* Also you need to make sure this class implements the ResultInterface
*
* @param string $classname
* @return self Provides fluent interface
*/
function
setResultClass
(
$classname
);
/**
* Get resultclass option
*
* @return string
*/
function
getResultClass
();
/**
* Get a helper instance
*
* @return Helper
*/
function
getHelper
();
/**
* Add extra params to the request
*
* Only intended for internal use, for instance with dereferenced params.
* Therefore the params are limited in functionality. Only add and get
*
* @param string $name
* @param string $value
* @return self Provides fluent interface
*/
function
addParam
(
$name
,
$value
);
/**
* Get extra params
*
* @return array
*/
public
function
getParams
();
}
\ No newline at end of file
library/Solarium/Core/Query/RequestBuilder.php
View file @
bb7dc32e
...
...
@@ -42,6 +42,7 @@
namespace
Solarium\Core\Query
;
use
Solarium\Core\Query\Query
;
use
Solarium\Core\Client\Request
;
use
Solarium\Core\Query\QueryInterface
;
/**
* Class for building Solarium client requests
...
...
@@ -49,7 +50,7 @@ use Solarium\Core\Client\Request;
* @package Solarium
* @subpackage Core
*/
abstract
class
RequestBuilder
abstract
class
RequestBuilder
implements
RequestBuilderInterface
{
/**
...
...
@@ -58,7 +59,7 @@ abstract class RequestBuilder
* @param Query $query
* @return Request
*/
public
function
build
(
$query
)
public
function
build
(
QueryInterface
$query
)
{
$request
=
new
Request
;
$request
->
setHandler
(
$query
->
getHandler
());
...
...
library/Solarium/Core/Query/RequestBuilderInterface.php
0 → 100644
View file @
bb7dc32e
<?php
/**
* Copyright 2011 Bas de Nooijer. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this listof conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are
* those of the authors and should not be interpreted as representing official
* policies, either expressed or implied, of the copyright holder.
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Core
*/
/**
* @namespace
*/
namespace
Solarium\Core\Query
;
use
Solarium\Core\Query\QueryInterface
;
use
Solarium\Core\Client\Request
;
/**
* Interface for requestbuilders
*
* @package Solarium
* @subpackage Core
*/
interface
RequestBuilderInterface
{
/**
* Build request for a select query
*
* @param QueryInterface $query
* @return Request
*/
function
build
(
QueryInterface
$query
);
}
\ No newline at end of file
library/Solarium/Core/Query/ResponseParser.php
→
library/Solarium/Core/Query/ResponseParser
Interface
.php
View file @
bb7dc32e
...
...
@@ -42,7 +42,7 @@
namespace
Solarium\Core\Query
;
/**
*
Base class for handling Solr response data
*
Interface for response parsers
*
* Most {@link Solarium\Client\Adapter} implementations will use HTTP for
* communicating with Solr. While the HTTP part is adapter-specific, the parsing
...
...
@@ -53,22 +53,17 @@ namespace Solarium\Core\Query;
* @package Solarium
* @subpackage Core
*/
abstract
class
ResponseParser
interface
ResponseParserInterface
{
/**
* Get a
Solarium\Result instance
for the given data
* Get a
Result object
for the given data
*
* When this method is called the actual response parsing is started.
*
* @internal Must be implemented in descendents because this parsing is
* query specific.
*
* @abstract
*
* @param Result\Result $result
* @return mixed
*/
abstract
function
parse
(
$result
);
function
parse
(
$result
);
}
\ No newline at end of file
library/Solarium/Core/Query/Result/QueryType.php
View file @
bb7dc32e
...
...
@@ -41,6 +41,7 @@
*/
namespace
Solarium\Core\Query\Result
;
use
Solarium\Core\Exception
;
use
Solarium\Core\Query\ResponseParserInterface
;
/**
* QueryType result
...
...
@@ -70,7 +71,7 @@ class QueryType extends Result
if
(
!
$this
->
parsed
)
{
$responseParser
=
$this
->
query
->
getResponseParser
();
if
(
!
$responseParser
)
{
if
(
!
$responseParser
||
!
(
$responseParser
instanceof
ResponseParserInterface
)
)
{
throw
new
Exception
(
'No responseparser returned by querytype: '
.
$this
->
query
->
getType
());
}
...
...
library/Solarium/Core/Query/Result/Result.php
View file @
bb7dc32e
...
...
@@ -56,7 +56,7 @@ use Solarium\Core\Query\Query;
* @package Solarium
* @subpackage Result
*/
class
Result
class
Result
implements
ResultInterface
{
/**
...
...
library/Solarium/Core/Query/Result/ResultInterface.php
0 → 100644
View file @
bb7dc32e
<?php
/**
* Copyright 2011 Bas de Nooijer. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this listof conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are
* those of the authors and should not be interpreted as representing official
* policies, either expressed or implied, of the copyright holder.
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Result
*/
/**
* @namespace
*/
namespace
Solarium\Core\Query\Result
;
use
Solarium\Core\Client\Response
;
use
Solarium\Core\Query\Query
;
/**
* Query result interface
*
* @package Solarium
* @subpackage Result
*/
interface
ResultInterface
{
/**
* Get response object
*
* This is the raw HTTP response object, not the parsed data!
*
* @return Response
*/
function
getResponse
();
/**
* Get query instance
*
* @return Query
*/
function
getQuery
();
/**
* Get Solr response data
*
* Includes a lazy loading mechanism: JSON body data is decoded on first use and then saved for reuse.
*
* @return array
*/
function
getData
();
}
\ No newline at end of file
library/Solarium/Query/Analysis/RequestBuilder/Document.php
View file @
bb7dc32e
...
...
@@ -42,6 +42,7 @@
namespace
Solarium\Query\Analysis\RequestBuilder
;
use
Solarium\Core\Query\RequestBuilder
as
BaseRequestBuilder
;
use
Solarium\Core\Client\Request
;
use
Solarium\Core\Query\QueryInterface
;
/**
* Build a document analysis request
...
...
@@ -58,7 +59,7 @@ class Document extends BaseRequestBuilder
* @param Document $query
* @return Request
*/
public
function
build
(
$query
)
public
function
build
(
QueryInterface
$query
)
{
$request
=
parent
::
build
(
$query
);
$request
->
setRawData
(
$this
->
getRawData
(
$query
));
...
...
library/Solarium/Query/Analysis/RequestBuilder/Field.php
View file @
bb7dc32e
...
...
@@ -42,6 +42,8 @@
namespace
Solarium\Query\Analysis\RequestBuilder
;
use
Solarium\Query\Analysis\Query\Field
as
QueryField
;
use
Solarium\Core\Client\Request
;
use
Solarium\Core\Query\QueryInterface
;
/**
* Build a field analysis request
*
...
...
@@ -57,7 +59,7 @@ class Field extends RequestBuilder
* @param QueryField $query
* @return Request
*/
public
function
build
(
$query
)
public
function
build
(
QueryInterface
$query
)
{
$request
=
parent
::
build
(
$query
);
...
...
library/Solarium/Query/Analysis/RequestBuilder/RequestBuilder.php
View file @
bb7dc32e
...
...
@@ -44,6 +44,7 @@ use Solarium\Core\Query\RequestBuilder as BaseRequestBuilder;
use
Solarium\Core\Client\Client
;
use
Solarium\Core\Client\Request
;
use
Solarium\Query\Analysis\Query\Query
;
use
Solarium\Core\Query\QueryInterface
;
/**
* Build an analysis request
...
...
@@ -60,7 +61,7 @@ class RequestBuilder extends BaseRequestBuilder
* @param Query $query
* @return Request
*/
public
function
build
(
$query
)
public
function
build
(
QueryInterface
$query
)
{
$request
=
parent
::
build
(
$query
);
$request
->
addParam
(
'analysis.query'
,
$query
->
getQuery
());
...
...
library/Solarium/Query/Analysis/ResponseParser/Field.php
View file @
bb7dc32e
...
...
@@ -42,15 +42,15 @@
namespace
Solarium\Query\Analysis\ResponseParser
;
use
Solarium\Core\Query\Result\Result
;
use
Solarium\Query\Analysis\Result
as
AnalysisResult
;
use
Solarium\Core\Query\ResponseParser
as
BaseResponseParser
;
use
Solarium\Core\Query\ResponseParser
Interface
;
/**
* Parse document analysis response data
*
* @package Solarium
* @subpackage Query
Type
* @subpackage Query
*/
class
Field
extends
BaseResponseParser
class
Field
implements
ResponseParserInterface
{
/**
...
...
library/Solarium/Query/MoreLikeThis/RequestBuilder.php
View file @
bb7dc32e
...
...
@@ -45,6 +45,7 @@
namespace
Solarium\Query\MoreLikeThis
;
use
Solarium\Core\Client\Request
;
use
Solarium\Query\Select\RequestBuilder\RequestBuilder
as
SelectRequestBuilder
;
use
Solarium\Core\Query\QueryInterface
;
/**
* Build a MoreLikeThis request
...
...
@@ -61,7 +62,7 @@ class RequestBuilder extends SelectRequestBuilder
* @param Query $query
* @return Request
*/
public
function
build
(
$query
)
public
function
build
(
QueryInterface
$query
)
{
$request
=
parent
::
build
(
$query
);
...
...
library/Solarium/Query/Ping/RequestBuilder.php
View file @
bb7dc32e
...
...
@@ -42,6 +42,7 @@
namespace
Solarium\Query\Ping
;
use
Solarium\Core\Client\Request
;
use
Solarium\Core\Query\RequestBuilder
as
BaseRequestBuilder
;
use
Solarium\Core\Query\QueryInterface
;
/**
* Build a ping request
...
...
@@ -58,7 +59,7 @@ class RequestBuilder extends BaseRequestBuilder
* @param Query $query
* @return Request
*/
public
function
build
(
$query
)
public
function
build
(
QueryInterface
$query
)
{
$request
=
parent
::
build
(
$query
);
$request
->
setMethod
(
Request
::
METHOD_GET
);
...
...
library/Solarium/Query/Select/RequestBuilder/RequestBuilder.php
View file @
bb7dc32e
...
...
@@ -43,6 +43,7 @@ namespace Solarium\Query\Select\RequestBuilder;
use
Solarium\Query\Select\Query\Query
as
SelectQuery
;
use
Solarium\Core\Client\Request
;
use
Solarium\Core\Query\RequestBuilder
as
BaseRequestBuilder
;
use
Solarium\Core\Query\QueryInterface
;
/**
* Build a select request
...
...
@@ -59,7 +60,7 @@ class RequestBuilder extends BaseRequestBuilder
* @param SelectQuery $query
* @return Request
*/
public
function
build
(
$query
)
public
function
build
(
QueryInterface
$query
)
{
$request
=
parent
::
build
(
$query
);
...
...
library/Solarium/Query/Select/ResponseParser/ResponseParser.php
View file @
bb7dc32e
...
...
@@ -40,7 +40,7 @@
* @namespace
*/
namespace
Solarium\Query\Select\ResponseParser
;
use
Solarium\Core\Query\ResponseParser
as
BaseResponseParser
;
use
Solarium\Core\Query\ResponseParser
Interface
;
use
Solarium\Query\Select\Result\Result
;
/**
...
...
@@ -49,7 +49,7 @@ use Solarium\Query\Select\Result\Result;
* @package Solarium
* @subpackage Query
*/
class
ResponseParser
extends
BaseResponseParser
class
ResponseParser
implements
ResponseParserInterface
{
/**
...
...
library/Solarium/Query/Suggester/RequestBuilder.php
View file @
bb7dc32e
...
...
@@ -42,6 +42,7 @@
namespace
Solarium\Query\Suggester
;
use
Solarium\Core\Client\Request
;
use
Solarium\Core\Query\RequestBuilder
as
BaseRequestBuilder
;
use
Solarium\Core\Query\QueryInterface
;
/**
* Build a Suggester query request
...
...
@@ -58,7 +59,7 @@ class RequestBuilder extends BaseRequestBuilder
* @param Query $query
* @return Request
*/
public
function
build
(
$query
)
public
function
build
(
QueryInterface
$query
)
{
$request
=
parent
::
build
(
$query
);
$request
->
addParam
(
'spellcheck'
,
'true'
);
...
...
library/Solarium/Query/Suggester/ResponseParser.php
View file @
bb7dc32e
...
...
@@ -42,7 +42,7 @@
*/
namespace
Solarium\Query\Suggester
;
use
Solarium\Client
;
use
Solarium\Core\Query\ResponseParser
as
BaseResponseParser
;
use
Solarium\Core\Query\ResponseParser
Interface
;
/**
* Parse Suggester response data
...
...
@@ -50,7 +50,7 @@ use Solarium\Core\Query\ResponseParser as BaseResponseParser;
* @package Solarium
* @subpackage QueryType
*/
class
ResponseParser
extends
BaseResponseParser
class
ResponseParser
implements
ResponseParserInterface
{
/**
...
...
library/Solarium/Query/Terms/RequestBuilder.php
View file @
bb7dc32e
...
...
@@ -45,6 +45,7 @@
namespace
Solarium\Query\Terms
;
use
Solarium\Core\Query\RequestBuilder
as
BaseRequestBuilder
;
use
Solarium\Core\Client\Request
;
use
Solarium\Core\Query\QueryInterface
;
/**
* Build a Terms query request
...
...
@@ -61,7 +62,7 @@ class RequestBuilder extends BaseRequestBuilder
* @param Query $query
* @return Request
*/
public
function
build
(
$query
)
public
function
build
(
QueryInterface
$query
)
{
$request
=
parent
::
build
(
$query
);
$request
->
setHandler
(
$query
->
getHandler
());
...
...
library/Solarium/Query/Terms/ResponseParser.php
View file @
bb7dc32e
...
...
@@ -41,7 +41,7 @@
* @namespace
*/
namespace
Solarium\Query\Terms
;
use
Solarium\Core\Query\ResponseParser
as
BaseResponseParser
;
use
Solarium\Core\Query\ResponseParser
Interface
;
use
Solarium\Core\Client\Request
;
/**
...
...
@@ -50,7 +50,7 @@ use Solarium\Core\Client\Request;
* @package Solarium
* @subpackage QueryType
*/
class
ResponseParser
extends
BaseResponseParser
class
ResponseParser
implements
ResponseParserInterface
{
/**
...
...
library/Solarium/Query/Update/RequestBuilder.php
View file @
bb7dc32e
...
...
@@ -45,6 +45,7 @@ use Solarium\Client;
use
Solarium\Core\Client\Request
;
use
Solarium\Query\Update\Query\Query
as
UpdateQuery
;
use
Solarium\Core\Query\RequestBuilder
as
BaseRequestBuilder
;
use
Solarium\Core\Query\QueryInterface
;
/**
* Build an update request
...
...
@@ -61,7 +62,7 @@ class RequestBuilder extends BaseRequestBuilder
* @param UpdateQuery $query
* @return Request
*/
public
function
build
(
$query
)
public
function
build
(
QueryInterface
$query
)
{
$request
=
parent
::
build
(
$query
);
$request
->
setMethod
(
Request
::
METHOD_POST
);
...
...
library/Solarium/Query/Update/ResponseParser.php
View file @
bb7dc32e
...
...
@@ -40,7 +40,7 @@
* @namespace
*/
namespace
Solarium\Query\Update
;
use
Solarium\Core\Query\ResponseParser
as
BaseResponseParser
;
use
Solarium\Core\Query\ResponseParser
Interface
;
/**
* Parse update response data
...
...
@@ -48,7 +48,7 @@ use Solarium\Core\Query\ResponseParser as BaseResponseParser;
* @package Solarium
* @subpackage QueryType
*/
class
ResponseParser
extends
BaseResponseParser
class
ResponseParser
implements
ResponseParserInterface
{
/**
...
...
tests/Solarium/Tests/Core/Client/ClientTest.php
View file @
bb7dc32e
...
...
@@ -466,7 +466,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase
{
$queryStub
=
$this
->
getMock
(
'Solarium\Query\Select\Query\Query'
);
$observer
=
$this
->
getMock
(
'Solarium\Core\
Client
\RequestBuilder'
,
array
(
'build'
));
$observer
=
$this
->
getMock
(
'Solarium\Core\
Query
\RequestBuilder'
,
array
(
'build'
));
$observer
->
expects
(
$this
->
once
())
->
method
(
'build'
)
->
with
(
$this
->
equalTo
(
$queryStub
));
...
...
@@ -706,7 +706,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase
$request
=
new
Request
();
$dummyResponse
=
'dummyresponse'
;
$observer
=
$this
->
getMock
(
'Solarium\Core\Client\Adapter\
Adapter
'
,
array
(
'execute'
));
$observer
=
$this
->
getMock
(
'Solarium\Core\Client\Adapter\
Http
'
,
array
(
'execute'
));
$observer
->
expects
(
$this
->
once
())
->
method
(
'execute'
)
->
with
(
$this
->
equalTo
(
$request
))
...
...
@@ -726,7 +726,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase
$request
=
new
Request
();
$dummyResponse
=
'dummyresponse'
;
$mockAdapter
=
$this
->
getMock
(
'Solarium\Core\Client\Adapter\
Adapter
'
,
array
(
'execute'
));
$mockAdapter
=
$this
->
getMock
(
'Solarium\Core\Client\Adapter\
Http
'
,
array
(
'execute'
));
$mockAdapter
->
expects
(
$this
->
once
())
->
method
(
'execute'
)
->
with
(
$this
->
equalTo
(
$request
))
...
...
@@ -747,7 +747,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase
$request
=
new
Request
();
$dummyResponse
=
'dummyresponse'
;
$mockAdapter
=
$this
->
getMock
(
'Solarium\Core\Client\Adapter\
Adapter
'
,
array
(
'execute'
));
$mockAdapter
=
$this
->
getMock
(
'Solarium\Core\Client\Adapter\
Http
'
,
array
(
'execute'
));
$mockAdapter
->
expects
(
$this
->
any
())
->
method
(
'execute'
)
->
with
(
$this
->
equalTo
(
$request
))
...
...
tests/Solarium/Tests/Plugin/BufferedAddTest.php
View file @
bb7dc32e
...
...
@@ -152,7 +152,7 @@ class BufferedAddTest extends \PHPUnit_Framework_TestCase
$data
=
array
(
'id'
=>
'123'
,
'name'
=>
'test'
);
$doc
=
new
Document
(
$data
);
$mockUpdate
=
$this
->
getMock
(
'Solarium\
Core\
Query\Update\Query\Query'
,
array
(
'addDocuments'
,
'addCommit'
));
$mockUpdate
=
$this
->
getMock
(
'Solarium\Query\Update\Query\Query'
,
array
(
'addDocuments'
,
'addCommit'
));
$mockUpdate
->
expects
(
$this
->
once
())
->
method
(
'addDocuments'
)
->
with
(
$this
->
equalTo
(
array
(
$doc
)),
$this
->
equalTo
(
true
));
$mockUpdate
->
expects
(
$this
->
once
())
->
method
(
'addCommit'
)
->
with
(
$this
->
equalTo
(
false
),
$this
->
equalTo
(
true
),
$this
->
equalTo
(
false
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment