Commit 84b4ed17 authored by Markus Kalkbrenner's avatar Markus Kalkbrenner Committed by GitHub

prepare that (some) components could be reused by other query types than select (#541)

parent 4b1fb0b0
...@@ -38,12 +38,12 @@ ...@@ -38,12 +38,12 @@
* @namespace * @namespace
*/ */
namespace Solarium\QueryType\Select\Query\Component; namespace Solarium\Component;
use Solarium\Core\Configurable; use Solarium\Core\Configurable;
use Solarium\Core\Query\AbstractQuery; use Solarium\Core\Query\AbstractQuery;
use Solarium\QueryType\Select\ResponseParser\Component\ComponentParserInterface; use Solarium\Component\ComponentParserInterface;
use Solarium\QueryType\Select\RequestBuilder\Component\ComponentRequestBuilderInterface; use Solarium\Component\ComponentRequestBuilderInterface;
/** /**
* Query component base class. * Query component base class.
......
<?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/
*/
/**
* @namespace
*/
namespace Solarium\Component;
use Solarium\Core\Query\AbstractQuery;
use Solarium\Exception\OutOfBoundsException;
/**
* Base class for all query types supporting components, not intended for direct usage.
*/
abstract class AbstractComponentAwareQuery extends AbstractQuery
{
/**
* Query component morelikethis.
*/
const COMPONENT_MORELIKETHIS = 'morelikethis';
/**
* Query component spellcheck.
*/
const COMPONENT_SPELLCHECK = 'spellcheck';
/**
* Query component spellcheck.
*/
const COMPONENT_SUGGESTER = 'suggest';
/**
* Query component debug.
*/
const COMPONENT_DEBUG = 'debug';
/**
* Query component spatial.
*/
const COMPONENT_SPATIAL = 'spatial';
/**
* Search components.
*
* @var AbstractComponent[]
*/
protected $components = array();
/**
* Default select query component types.
*
* @var array
*/
protected $componentTypes = array(
self::COMPONENT_MORELIKETHIS => 'Solarium\Component\MoreLikeThis',
self::COMPONENT_SPELLCHECK => 'Solarium\Component\Spellcheck',
self::COMPONENT_SUGGESTER => 'Solarium\Component\Suggester',
self::COMPONENT_DEBUG => 'Solarium\Component\Debug',
self::COMPONENT_SPATIAL => 'Solarium\Component\Spatial',
);
/**
* Get all registered component types.
*
* @return array
*/
public function getComponentTypes()
{
return $this->componentTypes;
}
/**
* Register a component type.
*
* @param string $key
* @param string $component
*
* @return self Provides fluent interface
*/
public function registerComponentType($key, $component)
{
$this->componentTypes[$key] = $component;
return $this;
}
/**
* Get all registered components.
*
* @return AbstractComponent[]
*/
public function getComponents()
{
return $this->components;
}
/**
* Get a component instance by key.
*
* You can optionally supply an autoload class to create a new component
* instance if there is no registered component for the given key yet.
*
* @throws OutOfBoundsException
*
* @param string $key Use one of the constants
* @param string|boolean $autoload Class to autoload if component needs to be created
* @param array|null $config Configuration to use for autoload
*
* @return object|null
*/
public function getComponent($key, $autoload = false, $config = null)
{
if (isset($this->components[$key])) {
return $this->components[$key];
} else {
if ($autoload === true) {
if (!isset($this->componentTypes[$key])) {
throw new OutOfBoundsException('Cannot autoload unknown component: '.$key);
}
$className = $this->componentTypes[$key];
$className = class_exists($className) ? $className : $className.strrchr($className, '\\');
$component = new $className($config);
$this->setComponent($key, $component);
return $component;
}
return;
}
}
/**
* Set a component instance.
*
* This overwrites any existing component registered with the same key.
*
* @param string $key
* @param AbstractComponent $component
*
* @return self Provides fluent interface
*/
public function setComponent($key, $component)
{
$component->setQueryInstance($this);
$this->components[$key] = $component;
return $this;
}
/**
* Remove a component instance.
*
* You can remove a component by passing its key or the component instance.
*
* @param string|AbstractComponent $component
*
* @return self Provides fluent interface
*/
public function removeComponent($component)
{
if (is_object($component)) {
foreach ($this->components as $key => $instance) {
if ($instance === $component) {
unset($this->components[$key]);
break;
}
}
} else {
if (isset($this->components[$component])) {
unset($this->components[$component]);
}
}
return $this;
}
/**
* Build component instances based on config.
*
* @param array $configs
*/
protected function createComponents($configs)
{
foreach ($configs as $type => $config) {
$this->getComponent($type, true, $config);
}
}
/**
* Get a MoreLikeThis component instance.
*
* This is a convenience method that maps presets to getComponent
*
* @return \Solarium\Component\MoreLikeThis
*/
public function getMoreLikeThis()
{
return $this->getComponent(self::COMPONENT_MORELIKETHIS, true);
}
/**
* Get a spellcheck component instance.
*
* This is a convenience method that maps presets to getComponent
*
* @return \Solarium\Component\Spellcheck
*/
public function getSpellcheck()
{
return $this->getComponent(self::COMPONENT_SPELLCHECK, true);
}
/**
* Get a suggest component instance.
*
* This is a convenience method that maps presets to getComponent
*
* @return \Solarium\Component\Spellcheck
*/
public function getSuggester()
{
return $this->getComponent(self::COMPONENT_SUGGESTER, true);
}
/**
* Get a Debug component instance.
*
* This is a convenience method that maps presets to getComponent
*
* @return \Solarium\Component\Debug
*/
public function getDebug()
{
return $this->getComponent(self::COMPONENT_DEBUG, true);
}
/**
* Get a Spatial component instance.
*
* This is a convenience method that maps presets to getComponent
*
* @return \Solarium\Component\Spatial
*/
public function getSpatial()
{
return $this->getComponent(self::COMPONENT_SPATIAL, true);
}
}
...@@ -38,11 +38,10 @@ ...@@ -38,11 +38,10 @@
* @namespace * @namespace
*/ */
namespace Solarium\QueryType\Select\Query\Component; namespace Solarium\Component;
use Solarium\QueryType\Select\Query\Query as SelectQuery; use Solarium\Component\RequestBuilder\Debug as RequestBuilder;
use Solarium\QueryType\Select\RequestBuilder\Component\Debug as RequestBuilder; use Solarium\Component\ResponseParser\Debug as ResponseParser;
use Solarium\QueryType\Select\ResponseParser\Component\Debug as ResponseParser;
/** /**
* Debug component. * Debug component.
...@@ -58,7 +57,7 @@ class Debug extends AbstractComponent ...@@ -58,7 +57,7 @@ class Debug extends AbstractComponent
*/ */
public function getType() public function getType()
{ {
return SelectQuery::COMPONENT_DEBUG; return AbstractComponentAwareQuery::COMPONENT_DEBUG;
} }
/** /**
......
...@@ -38,11 +38,10 @@ ...@@ -38,11 +38,10 @@
* @namespace * @namespace
*/ */
namespace Solarium\QueryType\Select\Query\Component; namespace Solarium\Component;
use Solarium\QueryType\Select\Query\Query as SelectQuery; use Solarium\Component\RequestBuilder\MoreLikeThis as RequestBuilder;
use Solarium\QueryType\Select\RequestBuilder\Component\MoreLikeThis as RequestBuilder; use Solarium\Component\ResponseParser\MoreLikeThis as ResponseParser;
use Solarium\QueryType\Select\ResponseParser\Component\MoreLikeThis as ResponseParser;
/** /**
* MoreLikeThis component. * MoreLikeThis component.
...@@ -58,7 +57,7 @@ class MoreLikeThis extends AbstractComponent ...@@ -58,7 +57,7 @@ class MoreLikeThis extends AbstractComponent
*/ */
public function getType() public function getType()
{ {
return SelectQuery::COMPONENT_MORELIKETHIS; return AbstractComponentAwareQuery::COMPONENT_MORELIKETHIS;
} }
/** /**
......
...@@ -38,9 +38,9 @@ ...@@ -38,9 +38,9 @@
* @namespace * @namespace
*/ */
namespace Solarium\QueryType\Select\RequestBuilder\Component; namespace Solarium\Component\RequestBuilder;
use Solarium\QueryType\Select\Query\Component\AbstractComponent; use Solarium\Component\AbstractComponent;
use Solarium\Core\Client\Request; use Solarium\Core\Client\Request;
/** /**
......
...@@ -38,9 +38,9 @@ ...@@ -38,9 +38,9 @@
* @namespace * @namespace
*/ */
namespace Solarium\QueryType\Select\RequestBuilder\Component; namespace Solarium\Component\RequestBuilder;
use Solarium\QueryType\Select\Query\Component\Debug as DebugComponent; use Solarium\Component\Debug as DebugComponent;
use Solarium\Core\Client\Request; use Solarium\Core\Client\Request;
/** /**
......
...@@ -38,9 +38,9 @@ ...@@ -38,9 +38,9 @@
* @namespace * @namespace
*/ */
namespace Solarium\QueryType\Select\RequestBuilder\Component; namespace Solarium\Component\RequestBuilder;
use Solarium\QueryType\Select\Query\Component\MoreLikeThis as MoreLikeThisComponent; use Solarium\Component\MoreLikeThis as MoreLikeThisComponent;
use Solarium\Core\Client\Request; use Solarium\Core\Client\Request;
/** /**
......
<?php <?php
namespace Solarium\QueryType\Select\RequestBuilder\Component; namespace Solarium\Component\RequestBuilder;
use Solarium\QueryType\Select\Query\Component\Spatial as SpatialComponent; use Solarium\Component\Spatial as SpatialComponent;
use Solarium\Core\Client\Request; use Solarium\Core\Client\Request;
/** /**
......
...@@ -34,13 +34,9 @@ ...@@ -34,13 +34,9 @@
* @link http://www.solarium-project.org/ * @link http://www.solarium-project.org/
*/ */
/** namespace Solarium\Component\RequestBuilder;
* @namespace
*/
namespace Solarium\QueryType\Select\RequestBuilder\Component;
use Solarium\QueryType\Select\Query\Component\Spellcheck as SpellcheckComponent; use Solarium\Component\Spellcheck as SpellcheckComponent;
use Solarium\Core\Client\Request; use Solarium\Core\Client\Request;
/** /**
......
...@@ -38,9 +38,9 @@ ...@@ -38,9 +38,9 @@
* @namespace * @namespace
*/ */
namespace Solarium\QueryType\Select\ResponseParser\Component; namespace Solarium\Component\ResponseParser;
use Solarium\QueryType\Select\Query\Query; use Solarium\Core\Query\AbstractQuery;
/** /**
* ComponentParserInterface. * ComponentParserInterface.
...@@ -50,9 +50,9 @@ interface ComponentParserInterface ...@@ -50,9 +50,9 @@ interface ComponentParserInterface
/** /**
* Parse result data into result objects. * Parse result data into result objects.
* *
* @param Query $query * @param AbstractQuery $query
* @param object $component * @param object $component
* @param array $data * @param array $data
* *
* @return object|null * @return object|null
*/ */
......
...@@ -38,16 +38,16 @@ ...@@ -38,16 +38,16 @@
* @namespace * @namespace
*/ */
namespace Solarium\QueryType\Select\ResponseParser\Component; namespace Solarium\Component\ResponseParser;
use Solarium\QueryType\Select\Query\Query; use Solarium\QueryType\Select\Query\Query;
use Solarium\QueryType\Select\Query\Component\Debug as DebugComponent; use Solarium\Component\Debug as DebugComponent;
use Solarium\QueryType\Select\Result\Debug\Result; use Solarium\Component\Result\Debug\Result;
use Solarium\QueryType\Select\Result\Debug\DocumentSet; use Solarium\Component\Result\Debug\DocumentSet;
use Solarium\QueryType\Select\Result\Debug\Timing; use Solarium\Component\Result\Debug\Timing;
use Solarium\QueryType\Select\Result\Debug\Detail; use Solarium\Component\Result\Debug\Detail;
use Solarium\QueryType\Select\Result\Debug\Document; use Solarium\Component\Result\Debug\Document;
use Solarium\QueryType\Select\Result\Debug\TimingPhase; use Solarium\Component\Result\Debug\TimingPhase;
/** /**
* Parse select component Debug result from the data. * Parse select component Debug result from the data.
......
...@@ -38,12 +38,12 @@ ...@@ -38,12 +38,12 @@
* @namespace * @namespace
*/ */
namespace Solarium\QueryType\Select\ResponseParser\Component; namespace Solarium\Component\ResponseParser;
use Solarium\QueryType\Select\Query\Query; use Solarium\QueryType\Analysis\Query\AbstractQuery;
use Solarium\QueryType\Select\Query\Component\MoreLikeThis as MoreLikeThisComponent; use Solarium\Component\MoreLikeThis as MoreLikeThisComponent;
use Solarium\QueryType\Select\Result\MoreLikeThis\Result; use Solarium\Component\Result\MoreLikeThis\Result;
use Solarium\QueryType\Select\Result\MoreLikeThis\MoreLikeThis as MoreLikeThisResult; use Solarium\Component\Result\MoreLikeThis\MoreLikeThis as MoreLikeThisResult;
/** /**
* Parse select component MoreLikeThis result from the data. * Parse select component MoreLikeThis result from the data.
...@@ -53,7 +53,7 @@ class MoreLikeThis implements ComponentParserInterface ...@@ -53,7 +53,7 @@ class MoreLikeThis implements ComponentParserInterface
/** /**
* Parse result data into result objects. * Parse result data into result objects.
* *
* @param Query $query * @param AbstractQuery $query
* @param MoreLikeThisComponent $moreLikeThis * @param MoreLikeThisComponent $moreLikeThis
* @param array $data * @param array $data
* *
......
...@@ -38,14 +38,14 @@ ...@@ -38,14 +38,14 @@
* @namespace * @namespace
*/ */
namespace Solarium\QueryType\Select\ResponseParser\Component; namespace Solarium\Component\ResponseParser;
use Solarium\QueryType\Select\Query\Query; use Solarium\Core\Query\AbstractQuery;
use Solarium\QueryType\Select\Query\Component\Spellcheck as SpellcheckComponent; use Solarium\Component\Spellcheck as SpellcheckComponent;
use Solarium\QueryType\Select\Result\Spellcheck as SpellcheckResult; use Solarium\Component\Result\Spellcheck as SpellcheckResult;
use Solarium\QueryType\Select\Result\Spellcheck\Result; use Solarium\Component\Result\Spellcheck\Result;
use Solarium\QueryType\Select\Result\Spellcheck\Collation; use Solarium\Component\Result\Spellcheck\Collation;
use Solarium\QueryType\Select\Result\Spellcheck\Suggestion; use Solarium\Component\Result\Spellcheck\Suggestion;
use Solarium\Core\Query\AbstractResponseParser as ResponseParserAbstract; use Solarium\Core\Query\AbstractResponseParser as ResponseParserAbstract;
/** /**
...@@ -56,7 +56,7 @@ class Spellcheck extends ResponseParserAbstract implements ComponentParserInterf ...@@ -56,7 +56,7 @@ class Spellcheck extends ResponseParserAbstract implements ComponentParserInterf
/** /**
* Parse result data into result objects. * Parse result data into result objects.
* *
* @param Query $query * @param AbstractQuery $query
* @param SpellcheckComponent $spellcheck * @param SpellcheckComponent $spellcheck
* @param array $data * @param array $data
* *
...@@ -123,7 +123,7 @@ class Spellcheck extends ResponseParserAbstract implements ComponentParserInterf ...@@ -123,7 +123,7 @@ class Spellcheck extends ResponseParserAbstract implements ComponentParserInterf
/** /**
* Parse collation data into a result object. * Parse collation data into a result object.
* *
* @param Query $queryObject * @param AbstractQuery $queryObject
* @param array $values * @param array $values
* *
* @return Collation[] * @return Collation[]
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
* @namespace * @namespace
*/ */
namespace Solarium\QueryType\Select\Result\Debug; namespace Solarium\Component\Result\Debug;
/** /**
* Select component debug detail result. * Select component debug detail result.
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
* @namespace * @namespace
*/ */
namespace Solarium\QueryType\Select\Result\Debug; namespace Solarium\Component\Result\Debug;
/** /**
* Select component debug document result. * Select component debug document result.
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
* @namespace * @namespace
*/ */
namespace Solarium\QueryType\Select\Result\Debug; namespace Solarium\Component\Result\Debug;
/** /**
* Select component debug documentset result. * Select component debug documentset result.
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
* @namespace * @namespace
*/ */
namespace Solarium\QueryType\Select\Result\Debug; namespace Solarium\Component\Result\Debug;
/** /**
* Select component debug result. * Select component debug result.
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
* @namespace * @namespace
*/ */
namespace Solarium\QueryType\Select\Result\Debug; namespace Solarium\Component\Result\Debug;
/** /**
* Select component debug timing result. * Select component debug timing result.
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
* @namespace * @namespace
*/ */
namespace Solarium\QueryType\Select\Result\Debug; namespace Solarium\Component\Result\Debug;
/** /**
* Select component debug timing phase result. * Select component debug timing phase result.
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
* @namespace * @namespace
*/ */
namespace Solarium\QueryType\Select\Result\MoreLikeThis; namespace Solarium\Component\Result\MoreLikeThis;
/** /**
* Select component morelikethis result. * Select component morelikethis result.
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
* @namespace * @namespace
*/ */
namespace Solarium\QueryType\Select\Result\MoreLikeThis; namespace Solarium\Component\Result\MoreLikeThis;
use Solarium\QueryType\Select\Result\DocumentInterface; use Solarium\QueryType\Select\Result\DocumentInterface;
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
* @namespace * @namespace
*/ */
namespace Solarium\QueryType\Select\Result\Spellcheck; namespace Solarium\Component\Result\Spellcheck;
/** /**
* Select component spellcheck collation result. * Select component spellcheck collation result.
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
* @namespace * @namespace
*/ */
namespace Solarium\QueryType\Select\Result\Spellcheck; namespace Solarium\Component\Result\Spellcheck;
/** /**
* Select component spellcheck result. * Select component spellcheck result.
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
* @namespace * @namespace
*/ */
namespace Solarium\QueryType\Select\Result\Spellcheck; namespace Solarium\Component\Result\Spellcheck;
/** /**
* Select component spellcheck suggestion result. * Select component spellcheck suggestion result.
......
<?php <?php
namespace Solarium\QueryType\Select\Query\Component; namespace Solarium\Component;
use Solarium\QueryType\Select\Query\Query as SelectQuery; use Solarium\Component\RequestBuilder\Spatial as RequestBuilder;
use Solarium\QueryType\Select\RequestBuilder\Component\Spatial as RequestBuilder;
/** /**
* Spatial component. * Spatial component.
...@@ -19,7 +18,7 @@ class Spatial extends AbstractComponent ...@@ -19,7 +18,7 @@ class Spatial extends AbstractComponent
*/ */
public function getType() public function getType()
{ {
return SelectQuery::COMPONENT_SPATIAL; return AbstractComponentAwareQuery::COMPONENT_SPATIAL;
} }
/** /**
......
...@@ -38,11 +38,10 @@ ...@@ -38,11 +38,10 @@
* @namespace * @namespace
*/ */
namespace Solarium\QueryType\Select\Query\Component; namespace Solarium\Component;
use Solarium\QueryType\Select\Query\Query as SelectQuery; use Solarium\Component\RequestBuilder\Spellcheck as RequestBuilder;
use Solarium\QueryType\Select\RequestBuilder\Component\Spellcheck as RequestBuilder; use Solarium\Component\ResponseParser\Spellcheck as ResponseParser;
use Solarium\QueryType\Select\ResponseParser\Component\Spellcheck as ResponseParser;
use Solarium\QueryType\Spellcheck\QueryTrait; use Solarium\QueryType\Spellcheck\QueryTrait;
/** /**
...@@ -62,7 +61,7 @@ class Spellcheck extends AbstractComponent ...@@ -62,7 +61,7 @@ class Spellcheck extends AbstractComponent
*/ */
public function getType() public function getType()
{ {
return SelectQuery::COMPONENT_SPELLCHECK; return AbstractComponentAwareQuery::COMPONENT_SPELLCHECK;
} }
/** /**
......
...@@ -38,11 +38,10 @@ ...@@ -38,11 +38,10 @@
* @namespace * @namespace
*/ */
namespace Solarium\QueryType\Select\Query\Component; namespace Solarium\Component;
use Solarium\QueryType\Select\Query\Query as SelectQuery; use Solarium\Component\RequestBuilder\Spellcheck as RequestBuilder;
use Solarium\QueryType\Select\RequestBuilder\Component\Spellcheck as RequestBuilder; use Solarium\Component\ResponseParser\Spellcheck as ResponseParser;
use Solarium\QueryType\Select\ResponseParser\Component\Spellcheck as ResponseParser;
use Solarium\QueryType\Suggester\QueryTrait; use Solarium\QueryType\Suggester\QueryTrait;
/** /**
...@@ -61,7 +60,7 @@ class Suggester extends AbstractComponent ...@@ -61,7 +60,7 @@ class Suggester extends AbstractComponent
*/ */
public function getType() public function getType()
{ {
return SelectQuery::COMPONENT_SUGGESTER; return AbstractComponentAwareQuery::COMPONENT_SUGGESTER;
} }
/** /**
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
namespace Solarium\QueryType\Select\Query\Component; namespace Solarium\QueryType\Select\Query\Component;
use Solarium\Component\AbstractComponent;
use Solarium\Exception\InvalidArgumentException; use Solarium\Exception\InvalidArgumentException;
use Solarium\QueryType\Select\Query\Query as SelectQuery; use Solarium\QueryType\Select\Query\Query as SelectQuery;
use Solarium\QueryType\Select\RequestBuilder\Component\DisMax as RequestBuilder; use Solarium\QueryType\Select\RequestBuilder\Component\DisMax as RequestBuilder;
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
namespace Solarium\QueryType\Select\Query\Component; namespace Solarium\QueryType\Select\Query\Component;
use Solarium\Component\AbstractComponent;
use Solarium\QueryType\Select\Query\Query as SelectQuery; use Solarium\QueryType\Select\Query\Query as SelectQuery;
use Solarium\QueryType\Select\RequestBuilder\Component\DistributedSearch as RequestBuilder; use Solarium\QueryType\Select\RequestBuilder\Component\DistributedSearch as RequestBuilder;
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
namespace Solarium\QueryType\Select\Query\Component; namespace Solarium\QueryType\Select\Query\Component;
use Solarium\Component\AbstractComponent;
use Solarium\QueryType\Select\Query\Query as SelectQuery; use Solarium\QueryType\Select\Query\Query as SelectQuery;
use Solarium\QueryType\Select\RequestBuilder\Component\FacetSet as RequestBuilder; use Solarium\QueryType\Select\RequestBuilder\Component\FacetSet as RequestBuilder;
use Solarium\QueryType\Select\ResponseParser\Component\FacetSet as ResponseParser; use Solarium\QueryType\Select\ResponseParser\Component\FacetSet as ResponseParser;
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
namespace Solarium\QueryType\Select\Query\Component; namespace Solarium\QueryType\Select\Query\Component;
use Solarium\Component\AbstractComponent;
use Solarium\QueryType\Select\Query\Query as SelectQuery; use Solarium\QueryType\Select\Query\Query as SelectQuery;
use Solarium\QueryType\Select\RequestBuilder\Component\Grouping as RequestBuilder; use Solarium\QueryType\Select\RequestBuilder\Component\Grouping as RequestBuilder;
use Solarium\QueryType\Select\ResponseParser\Component\Grouping as ResponseParser; use Solarium\QueryType\Select\ResponseParser\Component\Grouping as ResponseParser;
......
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
namespace Solarium\QueryType\Select\Query\Component\Highlighting; namespace Solarium\QueryType\Select\Query\Component\Highlighting;
use Solarium\QueryType\Select\Query\Query as SelectQuery; use Solarium\QueryType\Select\Query\Query as SelectQuery;
use Solarium\QueryType\Select\Query\Component\AbstractComponent; use Solarium\Component\AbstractComponent;
use Solarium\QueryType\Select\RequestBuilder\Component\Highlighting as RequestBuilder; use Solarium\QueryType\Select\RequestBuilder\Component\Highlighting as RequestBuilder;
use Solarium\QueryType\Select\ResponseParser\Component\Highlighting as ResponseParser; use Solarium\QueryType\Select\ResponseParser\Component\Highlighting as ResponseParser;
use Solarium\Exception\InvalidArgumentException; use Solarium\Exception\InvalidArgumentException;
......
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
namespace Solarium\QueryType\Select\Query\Component\Stats; namespace Solarium\QueryType\Select\Query\Component\Stats;
use Solarium\QueryType\Select\Query\Query as SelectQuery; use Solarium\QueryType\Select\Query\Query as SelectQuery;
use Solarium\QueryType\Select\Query\Component\AbstractComponent; use Solarium\Component\AbstractComponent;
use Solarium\QueryType\Select\RequestBuilder\Component\Stats as RequestBuilder; use Solarium\QueryType\Select\RequestBuilder\Component\Stats as RequestBuilder;
use Solarium\QueryType\Select\ResponseParser\Component\Stats as ResponseParser; use Solarium\QueryType\Select\ResponseParser\Component\Stats as ResponseParser;
use Solarium\Exception\InvalidArgumentException; use Solarium\Exception\InvalidArgumentException;
......
...@@ -40,13 +40,11 @@ ...@@ -40,13 +40,11 @@
namespace Solarium\QueryType\Select\Query; namespace Solarium\QueryType\Select\Query;
use Solarium\Component\AbstractComponentAwareQuery;
use Solarium\Core\Client\Client; use Solarium\Core\Client\Client;
use Solarium\Core\Query\AbstractQuery as BaseQuery;
use Solarium\QueryType\Select\RequestBuilder\RequestBuilder; use Solarium\QueryType\Select\RequestBuilder\RequestBuilder;
use Solarium\QueryType\Select\ResponseParser\ResponseParser; use Solarium\QueryType\Select\ResponseParser\ResponseParser;
use Solarium\Exception\InvalidArgumentException; use Solarium\Exception\InvalidArgumentException;
use Solarium\Exception\OutOfBoundsException;
use Solarium\QueryType\Select\Query\Component\AbstractComponent as AbstractComponent;
/** /**
* Select Query. * Select Query.
...@@ -55,7 +53,7 @@ use Solarium\QueryType\Select\Query\Component\AbstractComponent as AbstractCompo ...@@ -55,7 +53,7 @@ use Solarium\QueryType\Select\Query\Component\AbstractComponent as AbstractCompo
* lots of options and there are many Solarium subclasses for it. * lots of options and there are many Solarium subclasses for it.
* See the Solr documentation and the relevant Solarium classes for more info. * See the Solr documentation and the relevant Solarium classes for more info.
*/ */
class Query extends BaseQuery class Query extends AbstractComponentAwareQuery
{ {
/** /**
* Solr sort mode descending. * Solr sort mode descending.
...@@ -92,26 +90,11 @@ class Query extends BaseQuery ...@@ -92,26 +90,11 @@ class Query extends BaseQuery
*/ */
const COMPONENT_EDISMAX = 'edismax'; const COMPONENT_EDISMAX = 'edismax';
/**
* Query component morelikethis.
*/
const COMPONENT_MORELIKETHIS = 'morelikethis';
/** /**
* Query component highlighting. * Query component highlighting.
*/ */
const COMPONENT_HIGHLIGHTING = 'highlighting'; const COMPONENT_HIGHLIGHTING = 'highlighting';
/**
* Query component spellcheck.
*/
const COMPONENT_SPELLCHECK = 'spellcheck';
/**
* Query component spellcheck.
*/
const COMPONENT_SUGGESTER = 'suggest';
/** /**
* Query component grouping. * Query component grouping.
*/ */
...@@ -127,16 +110,6 @@ class Query extends BaseQuery ...@@ -127,16 +110,6 @@ class Query extends BaseQuery
*/ */
const COMPONENT_STATS = 'stats'; const COMPONENT_STATS = 'stats';
/**
* Query component debug.
*/
const COMPONENT_DEBUG = 'debug';
/**
* Query component spatial.
*/
const COMPONENT_SPATIAL = 'spatial';
/** /**
* Default options. * Default options.
* *
...@@ -169,14 +142,15 @@ class Query extends BaseQuery ...@@ -169,14 +142,15 @@ class Query extends BaseQuery
self::COMPONENT_FACETSET => 'Solarium\QueryType\Select\Query\Component\FacetSet', self::COMPONENT_FACETSET => 'Solarium\QueryType\Select\Query\Component\FacetSet',
self::COMPONENT_DISMAX => 'Solarium\QueryType\Select\Query\Component\DisMax', self::COMPONENT_DISMAX => 'Solarium\QueryType\Select\Query\Component\DisMax',
self::COMPONENT_EDISMAX => 'Solarium\QueryType\Select\Query\Component\EdisMax', self::COMPONENT_EDISMAX => 'Solarium\QueryType\Select\Query\Component\EdisMax',
self::COMPONENT_MORELIKETHIS => 'Solarium\QueryType\Select\Query\Component\MoreLikeThis', parent::COMPONENT_MORELIKETHIS => 'Solarium\Component\MoreLikeThis',
self::COMPONENT_HIGHLIGHTING => 'Solarium\QueryType\Select\Query\Component\Highlighting\Highlighting', self::COMPONENT_HIGHLIGHTING => 'Solarium\QueryType\Select\Query\Component\Highlighting\Highlighting',
self::COMPONENT_GROUPING => 'Solarium\QueryType\Select\Query\Component\Grouping', self::COMPONENT_GROUPING => 'Solarium\QueryType\Select\Query\Component\Grouping',
self::COMPONENT_SPELLCHECK => 'Solarium\QueryType\Select\Query\Component\Spellcheck', parent::COMPONENT_SPELLCHECK => 'Solarium\Component\Spellcheck',
parent::COMPONENT_SUGGESTER => 'Solarium\Component\Suggester',
self::COMPONENT_DISTRIBUTEDSEARCH => 'Solarium\QueryType\Select\Query\Component\DistributedSearch', self::COMPONENT_DISTRIBUTEDSEARCH => 'Solarium\QueryType\Select\Query\Component\DistributedSearch',
self::COMPONENT_STATS => 'Solarium\QueryType\Select\Query\Component\Stats\Stats', self::COMPONENT_STATS => 'Solarium\QueryType\Select\Query\Component\Stats\Stats',
self::COMPONENT_DEBUG => 'Solarium\QueryType\Select\Query\Component\Debug', parent::COMPONENT_DEBUG => 'Solarium\Component\Debug',
self::COMPONENT_SPATIAL => 'Solarium\QueryType\Select\Query\Component\Spatial', parent::COMPONENT_SPATIAL => 'Solarium\Component\Spatial',
); );
/** /**
...@@ -200,13 +174,6 @@ class Query extends BaseQuery ...@@ -200,13 +174,6 @@ class Query extends BaseQuery
*/ */
protected $filterQueries = array(); protected $filterQueries = array();
/**
* Search components.
*
* @var AbstractComponent[]
*/
protected $components = array();
/** /**
* Get type for this query. * Get type for this query.
* *
...@@ -748,134 +715,6 @@ class Query extends BaseQuery ...@@ -748,134 +715,6 @@ class Query extends BaseQuery
$this->addFilterQueries($filterQueries); $this->addFilterQueries($filterQueries);
} }
/**
* Get all registered component types.
*
* @return array
*/
public function getComponentTypes()
{
return $this->componentTypes;
}
/**
* Register a component type.
*
* @param string $key
* @param string $component
*
* @return self Provides fluent interface
*/
public function registerComponentType($key, $component)
{
$this->componentTypes[$key] = $component;
return $this;
}
/**
* Get all registered components.
*
* @return AbstractComponent[]
*/
public function getComponents()
{
return $this->components;
}
/**
* Get a component instance by key.
*
* You can optionally supply an autoload class to create a new component
* instance if there is no registered component for the given key yet.
*
* @throws OutOfBoundsException
*
* @param string $key Use one of the constants
* @param string|boolean $autoload Class to autoload if component needs to be created
* @param array|null $config Configuration to use for autoload
*
* @return object|null
*/
public function getComponent($key, $autoload = false, $config = null)
{
if (isset($this->components[$key])) {
return $this->components[$key];
} else {
if ($autoload === true) {
if (!isset($this->componentTypes[$key])) {
throw new OutOfBoundsException('Cannot autoload unknown component: '.$key);
}
$className = $this->componentTypes[$key];
$className = class_exists($className) ? $className : $className.strrchr($className, '\\');
$component = new $className($config);
$this->setComponent($key, $component);
return $component;
}
return;
}
}
/**
* Set a component instance.
*
* This overwrites any existing component registered with the same key.
*
* @param string $key
* @param AbstractComponent $component
*
* @return self Provides fluent interface
*/
public function setComponent($key, $component)
{
$component->setQueryInstance($this);
$this->components[$key] = $component;
return $this;
}
/**
* Remove a component instance.
*
* You can remove a component by passing its key or the component instance.
*
* @param string|AbstractComponent $component
*
* @return self Provides fluent interface
*/
public function removeComponent($component)
{
if (is_object($component)) {
foreach ($this->components as $key => $instance) {
if ($instance === $component) {
unset($this->components[$key]);
break;
}
}
} else {
if (isset($this->components[$component])) {
unset($this->components[$component]);
}
}
return $this;
}
/**
* Get a MoreLikeThis component instance.
*
* This is a convenience method that maps presets to getComponent
*
* @return \Solarium\QueryType\Select\Query\Component\MoreLikeThis
*/
public function getMoreLikeThis()
{
return $this->getComponent(self::COMPONENT_MORELIKETHIS, true);
}
/** /**
* Get a FacetSet component instance. * Get a FacetSet component instance.
* *
...@@ -936,18 +775,6 @@ class Query extends BaseQuery ...@@ -936,18 +775,6 @@ class Query extends BaseQuery
return $this->getComponent(self::COMPONENT_GROUPING, true); return $this->getComponent(self::COMPONENT_GROUPING, true);
} }
/**
* Get a spellcheck component instance.
*
* This is a convenience method that maps presets to getComponent
*
* @return \Solarium\QueryType\Select\Query\Component\Spellcheck
*/
public function getSpellcheck()
{
return $this->getComponent(self::COMPONENT_SPELLCHECK, true);
}
/** /**
* Get a DistributedSearch component instance. * Get a DistributedSearch component instance.
* *
...@@ -972,18 +799,6 @@ class Query extends BaseQuery ...@@ -972,18 +799,6 @@ class Query extends BaseQuery
return $this->getComponent(self::COMPONENT_STATS, true); return $this->getComponent(self::COMPONENT_STATS, true);
} }
/**
* Get a Debug component instance.
*
* This is a convenience method that maps presets to getComponent
*
* @return \Solarium\QueryType\Select\Query\Component\Debug
*/
public function getDebug()
{
return $this->getComponent(self::COMPONENT_DEBUG, true);
}
/** /**
* Add a tag. * Add a tag.
* *
...@@ -1068,18 +883,6 @@ class Query extends BaseQuery ...@@ -1068,18 +883,6 @@ class Query extends BaseQuery
return $this->addTags($tags); return $this->addTags($tags);
} }
/**
* Get a Spatial component instance.
*
* This is a convenience method that maps presets to getComponent
*
* @return \Solarium\QueryType\Select\Query\Component\Spatial
*/
public function getSpatial()
{
return $this->getComponent(self::COMPONENT_SPATIAL, true);
}
/** /**
* Set the cursor mark to fetch. * Set the cursor mark to fetch.
* *
...@@ -1158,15 +961,4 @@ class Query extends BaseQuery ...@@ -1158,15 +961,4 @@ class Query extends BaseQuery
} }
} }
/**
* Build component instances based on config.
*
* @param array $configs
*/
protected function createComponents($configs)
{
foreach ($configs as $type => $config) {
$this->getComponent($type, true, $config);
}
}
} }
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
namespace Solarium\QueryType\Select\RequestBuilder\Component; namespace Solarium\QueryType\Select\RequestBuilder\Component;
use Solarium\Component\RequestBuilder\ComponentRequestBuilderInterface;
use Solarium\QueryType\Select\Query\Component\DisMax as DismaxComponent; use Solarium\QueryType\Select\Query\Component\DisMax as DismaxComponent;
use Solarium\Core\Client\Request; use Solarium\Core\Client\Request;
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
namespace Solarium\QueryType\Select\RequestBuilder\Component; namespace Solarium\QueryType\Select\RequestBuilder\Component;
use Solarium\Component\RequestBuilder\ComponentRequestBuilderInterface;
use Solarium\QueryType\Select\Query\Component\DistributedSearch as DistributedSearchComponent; use Solarium\QueryType\Select\Query\Component\DistributedSearch as DistributedSearchComponent;
use Solarium\Core\Client\Request; use Solarium\Core\Client\Request;
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
namespace Solarium\QueryType\Select\RequestBuilder\Component; namespace Solarium\QueryType\Select\RequestBuilder\Component;
use Solarium\Component\RequestBuilder\ComponentRequestBuilderInterface;
use Solarium\QueryType\Select\Query\Component\EdisMax as EdismaxComponent; use Solarium\QueryType\Select\Query\Component\EdisMax as EdismaxComponent;
use Solarium\Core\Client\Request; use Solarium\Core\Client\Request;
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
namespace Solarium\QueryType\Select\RequestBuilder\Component; namespace Solarium\QueryType\Select\RequestBuilder\Component;
use Solarium\Component\RequestBuilder\ComponentRequestBuilderInterface;
use Solarium\Core\Client\Request; use Solarium\Core\Client\Request;
use Solarium\QueryType\Select\RequestBuilder\RequestBuilder; use Solarium\QueryType\Select\RequestBuilder\RequestBuilder;
use Solarium\QueryType\Select\Query\Component\FacetSet as FacetsetComponent; use Solarium\QueryType\Select\Query\Component\FacetSet as FacetsetComponent;
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
namespace Solarium\QueryType\Select\RequestBuilder\Component; namespace Solarium\QueryType\Select\RequestBuilder\Component;
use Solarium\Component\RequestBuilder\ComponentRequestBuilderInterface;
use Solarium\QueryType\Select\Query\Component\Grouping as GroupingComponent; use Solarium\QueryType\Select\Query\Component\Grouping as GroupingComponent;
use Solarium\Core\Client\Request; use Solarium\Core\Client\Request;
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
namespace Solarium\QueryType\Select\RequestBuilder\Component; namespace Solarium\QueryType\Select\RequestBuilder\Component;
use Solarium\Component\RequestBuilder\ComponentRequestBuilderInterface;
use Solarium\QueryType\Select\Query\Component\Highlighting\Highlighting as HighlightingComponent; use Solarium\QueryType\Select\Query\Component\Highlighting\Highlighting as HighlightingComponent;
use Solarium\QueryType\Select\Query\Component\Highlighting\Field as HighlightingField; use Solarium\QueryType\Select\Query\Component\Highlighting\Field as HighlightingField;
use Solarium\Core\Client\Request; use Solarium\Core\Client\Request;
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
namespace Solarium\QueryType\Select\RequestBuilder\Component; namespace Solarium\QueryType\Select\RequestBuilder\Component;
use Solarium\Component\RequestBuilder\ComponentRequestBuilderInterface;
use Solarium\QueryType\Select\Query\Component\Stats\Stats as StatsComponent; use Solarium\QueryType\Select\Query\Component\Stats\Stats as StatsComponent;
use Solarium\Core\Client\Request; use Solarium\Core\Client\Request;
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
namespace Solarium\QueryType\Select\ResponseParser\Component; namespace Solarium\QueryType\Select\ResponseParser\Component;
use Solarium\Component\ResponseParser\ComponentParserInterface;
use Solarium\QueryType\Select\Query\Query; use Solarium\QueryType\Select\Query\Query;
use Solarium\QueryType\Select\Query\Component\FacetSet as QueryFacetSet; use Solarium\QueryType\Select\Query\Component\FacetSet as QueryFacetSet;
use Solarium\QueryType\Select\Query\Component\Facet\Field as QueryFacetField; use Solarium\QueryType\Select\Query\Component\Facet\Field as QueryFacetField;
...@@ -252,7 +253,7 @@ class FacetSet extends ResponseParserAbstract implements ComponentParserInterfac ...@@ -252,7 +253,7 @@ class FacetSet extends ResponseParserAbstract implements ComponentParserInterfac
return new ResultFacetRange($data['counts'], $before, $after, $between, $start, $end, $gap); return new ResultFacetRange($data['counts'], $before, $after, $between, $start, $end, $gap);
} }
/** /**
* Add a facet result for a interval facet * Add a facet result for a interval facet
* *
...@@ -267,7 +268,7 @@ class FacetSet extends ResponseParserAbstract implements ComponentParserInterfac ...@@ -267,7 +268,7 @@ class FacetSet extends ResponseParserAbstract implements ComponentParserInterfac
if (!isset($data['facet_counts']['facet_intervals'][$key])) { if (!isset($data['facet_counts']['facet_intervals'][$key])) {
return null; return null;
} }
return new ResultFacetInterval($data['facet_counts']['facet_intervals'][$key]); return new ResultFacetInterval($data['facet_counts']['facet_intervals'][$key]);
} }
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
namespace Solarium\QueryType\Select\ResponseParser\Component; namespace Solarium\QueryType\Select\ResponseParser\Component;
use Solarium\Component\ResponseParser\ComponentParserInterface;
use Solarium\QueryType\Select\Query\Query; use Solarium\QueryType\Select\Query\Query;
use Solarium\QueryType\Select\Query\Component\Grouping as GroupingComponent; use Solarium\QueryType\Select\Query\Component\Grouping as GroupingComponent;
use Solarium\QueryType\Select\Result\Grouping\Result; use Solarium\QueryType\Select\Result\Grouping\Result;
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
namespace Solarium\QueryType\Select\ResponseParser\Component; namespace Solarium\QueryType\Select\ResponseParser\Component;
use Solarium\Component\ResponseParser\ComponentParserInterface;
use Solarium\QueryType\Select\Query\Query; use Solarium\QueryType\Select\Query\Query;
use Solarium\QueryType\Select\Query\Component\Highlighting\Highlighting as HighlightingComponent; use Solarium\QueryType\Select\Query\Component\Highlighting\Highlighting as HighlightingComponent;
use Solarium\QueryType\Select\Result\Highlighting\Highlighting as HighlightingResult; use Solarium\QueryType\Select\Result\Highlighting\Highlighting as HighlightingResult;
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
namespace Solarium\QueryType\Select\ResponseParser\Component; namespace Solarium\QueryType\Select\ResponseParser\Component;
use Solarium\Component\ResponseParser\ComponentParserInterface;
use Solarium\QueryType\Select\Query\Query; use Solarium\QueryType\Select\Query\Query;
use Solarium\QueryType\Select\Query\Component\Stats\Stats as StatsComponent; use Solarium\QueryType\Select\Query\Component\Stats\Stats as StatsComponent;
use Solarium\QueryType\Select\Result\Stats\Stats as ResultStats; use Solarium\QueryType\Select\Result\Stats\Stats as ResultStats;
......
...@@ -29,9 +29,9 @@ ...@@ -29,9 +29,9 @@
* policies, either expressed or implied, of the copyright holder. * policies, either expressed or implied, of the copyright holder.
*/ */
namespace Solarium\Tests\QueryType\Select\Query\Component; namespace Solarium\Tests\Component;
use Solarium\QueryType\Select\Query\Component\AbstractComponent; use Solarium\Component\AbstractComponent;
use Solarium\QueryType\Select\Query\Query; use Solarium\QueryType\Select\Query\Query;
class ComponentTest extends \PHPUnit_Framework_TestCase class ComponentTest extends \PHPUnit_Framework_TestCase
......
...@@ -29,9 +29,9 @@ ...@@ -29,9 +29,9 @@
* policies, either expressed or implied, of the copyright holder. * policies, either expressed or implied, of the copyright holder.
*/ */
namespace Solarium\Tests\QueryType\Select\Result\Debug; namespace Solarium\Tests\Component\Result\Debug;
use Solarium\QueryType\Select\Result\Debug\Result; use Solarium\Component\Result\Debug\Result;
class DebugTest extends \PHPUnit_Framework_TestCase class DebugTest extends \PHPUnit_Framework_TestCase
{ {
......
...@@ -29,9 +29,9 @@ ...@@ -29,9 +29,9 @@
* policies, either expressed or implied, of the copyright holder. * policies, either expressed or implied, of the copyright holder.
*/ */
namespace Solarium\Tests\QueryType\Select\Result\Debug; namespace Solarium\Tests\Component\Result\Debug;
use Solarium\QueryType\Select\Result\Debug\Detail; use Solarium\Component\Result\Debug\Detail;
class DetailTest extends \PHPUnit_Framework_TestCase class DetailTest extends \PHPUnit_Framework_TestCase
{ {
......
...@@ -29,9 +29,9 @@ ...@@ -29,9 +29,9 @@
* policies, either expressed or implied, of the copyright holder. * policies, either expressed or implied, of the copyright holder.
*/ */
namespace Solarium\Tests\QueryType\Select\Result\Debug; namespace Solarium\Tests\Component\Result\Debug;
use Solarium\QueryType\Select\Result\Debug\DocumentSet; use Solarium\Component\Result\Debug\DocumentSet;
class DocumentSetTest extends \PHPUnit_Framework_TestCase class DocumentSetTest extends \PHPUnit_Framework_TestCase
{ {
......
...@@ -29,9 +29,9 @@ ...@@ -29,9 +29,9 @@
* policies, either expressed or implied, of the copyright holder. * policies, either expressed or implied, of the copyright holder.
*/ */
namespace Solarium\Tests\QueryType\Select\Result\Debug; namespace Solarium\Tests\Component\Result\Debug;
use Solarium\QueryType\Select\Result\Debug\Document; use Solarium\Component\Result\Debug\Document;
class DocumentTest extends \PHPUnit_Framework_TestCase class DocumentTest extends \PHPUnit_Framework_TestCase
{ {
......
...@@ -29,9 +29,9 @@ ...@@ -29,9 +29,9 @@
* policies, either expressed or implied, of the copyright holder. * policies, either expressed or implied, of the copyright holder.
*/ */
namespace Solarium\Tests\QueryType\Select\Result\Debug; namespace Solarium\Tests\Component\Result\Debug;
use Solarium\QueryType\Select\Result\Debug\TimingPhase; use Solarium\Component\Result\Debug\TimingPhase;
class TimingPhaseTest extends \PHPUnit_Framework_TestCase class TimingPhaseTest extends \PHPUnit_Framework_TestCase
{ {
......
...@@ -29,9 +29,9 @@ ...@@ -29,9 +29,9 @@
* policies, either expressed or implied, of the copyright holder. * policies, either expressed or implied, of the copyright holder.
*/ */
namespace Solarium\Tests\QueryType\Select\Result\Debug; namespace Solarium\Tests\Component\Result\Debug;
use Solarium\QueryType\Select\Result\Debug\Timing; use Solarium\Component\Result\Debug\Timing;
class TimingTest extends \PHPUnit_Framework_TestCase class TimingTest extends \PHPUnit_Framework_TestCase
{ {
......
...@@ -29,11 +29,11 @@ ...@@ -29,11 +29,11 @@
* policies, either expressed or implied, of the copyright holder. * policies, either expressed or implied, of the copyright holder.
*/ */
namespace Solarium\Tests\QueryType\Select\Result\MoreLikeThis; namespace Solarium\Tests\Component\Result\MoreLikeThis;
use Solarium\QueryType\Select\Result\Document; use Solarium\QueryType\Select\Result\Document;
use Solarium\QueryType\Select\Result\MoreLikeThis\Result; use Solarium\Component\Result\MoreLikeThis\Result;
use Solarium\QueryType\Select\Result\MoreLikeThis\MoreLikeThis; use Solarium\Component\Result\MoreLikeThis\MoreLikeThis;
class MoreLikeThisTest extends \PHPUnit_Framework_TestCase class MoreLikeThisTest extends \PHPUnit_Framework_TestCase
{ {
......
...@@ -29,10 +29,10 @@ ...@@ -29,10 +29,10 @@
* policies, either expressed or implied, of the copyright holder. * policies, either expressed or implied, of the copyright holder.
*/ */
namespace Solarium\Tests\QueryType\Select\Result\MoreLikeThis; namespace Solarium\Tests\Component\Result\MoreLikeThis;
use Solarium\QueryType\Select\Result\Document; use Solarium\QueryType\Select\Result\Document;
use Solarium\QueryType\Select\Result\MoreLikeThis\Result; use Solarium\Component\Result\MoreLikeThis\Result;
class ResultTest extends \PHPUnit_Framework_TestCase class ResultTest extends \PHPUnit_Framework_TestCase
{ {
......
...@@ -29,9 +29,9 @@ ...@@ -29,9 +29,9 @@
* policies, either expressed or implied, of the copyright holder. * policies, either expressed or implied, of the copyright holder.
*/ */
namespace Solarium\Tests\QueryType\Select\Result\Spellcheck; namespace Solarium\Tests\Component\Result\Spellcheck;
use Solarium\QueryType\Select\Result\Spellcheck\Collation; use Solarium\Component\Result\Spellcheck\Collation;
class CollationTest extends \PHPUnit_Framework_TestCase class CollationTest extends \PHPUnit_Framework_TestCase
{ {
......
...@@ -29,9 +29,9 @@ ...@@ -29,9 +29,9 @@
* policies, either expressed or implied, of the copyright holder. * policies, either expressed or implied, of the copyright holder.
*/ */
namespace Solarium\Tests\QueryType\Select\Result\Spellcheck; namespace Solarium\Tests\Component\Result\Spellcheck;
use Solarium\QueryType\Select\Result\Spellcheck\Result; use Solarium\Component\Result\Spellcheck\Result;
class SpellcheckTest extends \PHPUnit_Framework_TestCase class SpellcheckTest extends \PHPUnit_Framework_TestCase
{ {
......
...@@ -29,9 +29,9 @@ ...@@ -29,9 +29,9 @@
* policies, either expressed or implied, of the copyright holder. * policies, either expressed or implied, of the copyright holder.
*/ */
namespace Solarium\Tests\QueryType\Select\Result\Spellcheck; namespace Solarium\Tests\Component\Result\Spellcheck;
use Solarium\QueryType\Select\Result\Spellcheck\Suggestion; use Solarium\Component\Result\Spellcheck\Suggestion;
class SuggestionTest extends \PHPUnit_Framework_TestCase class SuggestionTest extends \PHPUnit_Framework_TestCase
{ {
......
...@@ -29,6 +29,14 @@ abstract class AbstractTechproductsTest extends \PHPUnit_Framework_TestCase ...@@ -29,6 +29,14 @@ abstract class AbstractTechproductsTest extends \PHPUnit_Framework_TestCase
]; ];
$this->client = new \Solarium\Client($config); $this->client = new \Solarium\Client($config);
try {
$ping = $this->client->createPing();
$this->client->ping($ping);
}
catch (\Exception $e) {
$this->markTestSkipped('Solr techproducts example not reachable.');
}
} }
/** /**
......
...@@ -34,7 +34,7 @@ namespace Solarium\Tests\QueryType\MoreLikeThis; ...@@ -34,7 +34,7 @@ namespace Solarium\Tests\QueryType\MoreLikeThis;
use Solarium\QueryType\MoreLikeThis\Query; use Solarium\QueryType\MoreLikeThis\Query;
use Solarium\Core\Client\Client; use Solarium\Core\Client\Client;
use Solarium\QueryType\Select\Query\FilterQuery; use Solarium\QueryType\Select\Query\FilterQuery;
use Solarium\QueryType\Select\Query\Component\MoreLikeThis; use Solarium\Component\MoreLikeThis;
class QueryTest extends \PHPUnit_Framework_TestCase class QueryTest extends \PHPUnit_Framework_TestCase
{ {
...@@ -551,7 +551,7 @@ class QueryTest extends \PHPUnit_Framework_TestCase ...@@ -551,7 +551,7 @@ class QueryTest extends \PHPUnit_Framework_TestCase
$mlt = $this->query->getMoreLikeThis(); $mlt = $this->query->getMoreLikeThis();
$this->assertEquals( $this->assertEquals(
'Solarium\QueryType\Select\Query\Component\MoreLikeThis', 'Solarium\Component\MoreLikeThis',
get_class($mlt) get_class($mlt)
); );
} }
...@@ -620,7 +620,7 @@ class QueryTest extends \PHPUnit_Framework_TestCase ...@@ -620,7 +620,7 @@ class QueryTest extends \PHPUnit_Framework_TestCase
$spellcheck = $this->query->getSpellcheck(); $spellcheck = $this->query->getSpellcheck();
$this->assertEquals( $this->assertEquals(
'Solarium\QueryType\Select\Query\Component\Spellcheck', 'Solarium\Component\Spellcheck',
get_class($spellcheck) get_class($spellcheck)
); );
} }
...@@ -650,7 +650,7 @@ class QueryTest extends \PHPUnit_Framework_TestCase ...@@ -650,7 +650,7 @@ class QueryTest extends \PHPUnit_Framework_TestCase
$stats = $this->query->getDebug(); $stats = $this->query->getDebug();
$this->assertEquals( $this->assertEquals(
'Solarium\QueryType\Select\Query\Component\Debug', 'Solarium\Component\Debug',
get_class($stats) get_class($stats)
); );
} }
......
...@@ -34,7 +34,7 @@ namespace Solarium\Tests\QueryType\Select\Query; ...@@ -34,7 +34,7 @@ namespace Solarium\Tests\QueryType\Select\Query;
use Solarium\QueryType\Select\Query\Query; use Solarium\QueryType\Select\Query\Query;
use Solarium\QueryType\Select\Query\FilterQuery; use Solarium\QueryType\Select\Query\FilterQuery;
use Solarium\Core\Client\Client; use Solarium\Core\Client\Client;
use Solarium\QueryType\Select\Query\Component\MoreLikeThis; use Solarium\Component\MoreLikeThis;
abstract class AbstractQueryTest extends \PHPUnit_Framework_TestCase abstract class AbstractQueryTest extends \PHPUnit_Framework_TestCase
{ {
...@@ -572,7 +572,7 @@ abstract class AbstractQueryTest extends \PHPUnit_Framework_TestCase ...@@ -572,7 +572,7 @@ abstract class AbstractQueryTest extends \PHPUnit_Framework_TestCase
$mlt = $this->query->getMoreLikeThis(); $mlt = $this->query->getMoreLikeThis();
$this->assertEquals( $this->assertEquals(
'Solarium\QueryType\Select\Query\Component\MoreLikeThis', 'Solarium\Component\MoreLikeThis',
get_class($mlt) get_class($mlt)
); );
} }
...@@ -641,11 +641,21 @@ abstract class AbstractQueryTest extends \PHPUnit_Framework_TestCase ...@@ -641,11 +641,21 @@ abstract class AbstractQueryTest extends \PHPUnit_Framework_TestCase
$spellcheck = $this->query->getSpellcheck(); $spellcheck = $this->query->getSpellcheck();
$this->assertEquals( $this->assertEquals(
'Solarium\QueryType\Select\Query\Component\Spellcheck', 'Solarium\Component\Spellcheck',
get_class($spellcheck) get_class($spellcheck)
); );
} }
public function testGetSuggester()
{
$suggester = $this->query->getSuggester();
$this->assertEquals(
'Solarium\Component\Suggester',
get_class($suggester)
);
}
public function testGetDistributedSearch() public function testGetDistributedSearch()
{ {
$spellcheck = $this->query->getDistributedSearch(); $spellcheck = $this->query->getDistributedSearch();
...@@ -671,7 +681,7 @@ abstract class AbstractQueryTest extends \PHPUnit_Framework_TestCase ...@@ -671,7 +681,7 @@ abstract class AbstractQueryTest extends \PHPUnit_Framework_TestCase
$stats = $this->query->getDebug(); $stats = $this->query->getDebug();
$this->assertEquals( $this->assertEquals(
'Solarium\QueryType\Select\Query\Component\Debug', 'Solarium\Component\Debug',
get_class($stats) get_class($stats)
); );
} }
...@@ -714,7 +724,7 @@ abstract class AbstractQueryTest extends \PHPUnit_Framework_TestCase ...@@ -714,7 +724,7 @@ abstract class AbstractQueryTest extends \PHPUnit_Framework_TestCase
$spatial = $this->query->getSpatial(); $spatial = $this->query->getSpatial();
$this->assertEquals( $this->assertEquals(
'Solarium\QueryType\Select\Query\Component\Spatial', 'Solarium\Component\Spatial',
get_class($spatial) get_class($spatial)
); );
} }
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
namespace Solarium\Tests\QueryType\Select\Query\Component; namespace Solarium\Tests\QueryType\Select\Query\Component;
use Solarium\QueryType\Select\Query\Component\Debug; use Solarium\Component\Debug;
use Solarium\QueryType\Select\Query\Query; use Solarium\QueryType\Select\Query\Query;
class DebugTest extends \PHPUnit_Framework_TestCase class DebugTest extends \PHPUnit_Framework_TestCase
...@@ -68,7 +68,7 @@ class DebugTest extends \PHPUnit_Framework_TestCase ...@@ -68,7 +68,7 @@ class DebugTest extends \PHPUnit_Framework_TestCase
public function testGetResponseParser() public function testGetResponseParser()
{ {
$this->assertInstanceOf( $this->assertInstanceOf(
'Solarium\QueryType\Select\ResponseParser\Component\Debug', 'Solarium\Component\ResponseParser\Debug',
$this->debug->getResponseParser() $this->debug->getResponseParser()
); );
} }
...@@ -76,7 +76,7 @@ class DebugTest extends \PHPUnit_Framework_TestCase ...@@ -76,7 +76,7 @@ class DebugTest extends \PHPUnit_Framework_TestCase
public function testGetRequestBuilder() public function testGetRequestBuilder()
{ {
$this->assertInstanceOf( $this->assertInstanceOf(
'Solarium\QueryType\Select\RequestBuilder\Component\Debug', 'Solarium\Component\RequestBuilder\Debug',
$this->debug->getRequestBuilder() $this->debug->getRequestBuilder()
); );
} }
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
namespace Solarium\Tests\QueryType\Select\Query\Component; namespace Solarium\Tests\QueryType\Select\Query\Component;
use Solarium\QueryType\Select\Query\Component\MoreLikeThis; use Solarium\Component\MoreLikeThis;
use Solarium\QueryType\Select\Query\Query; use Solarium\QueryType\Select\Query\Query;
class MoreLikeThisTest extends \PHPUnit_Framework_TestCase class MoreLikeThisTest extends \PHPUnit_Framework_TestCase
...@@ -82,7 +82,7 @@ class MoreLikeThisTest extends \PHPUnit_Framework_TestCase ...@@ -82,7 +82,7 @@ class MoreLikeThisTest extends \PHPUnit_Framework_TestCase
public function testGetResponseParser() public function testGetResponseParser()
{ {
$this->assertInstanceOf( $this->assertInstanceOf(
'Solarium\QueryType\Select\ResponseParser\Component\MoreLikeThis', 'Solarium\Component\ResponseParser\MoreLikeThis',
$this->mlt->getResponseParser() $this->mlt->getResponseParser()
); );
} }
...@@ -90,7 +90,7 @@ class MoreLikeThisTest extends \PHPUnit_Framework_TestCase ...@@ -90,7 +90,7 @@ class MoreLikeThisTest extends \PHPUnit_Framework_TestCase
public function testGetRequestBuilder() public function testGetRequestBuilder()
{ {
$this->assertInstanceOf( $this->assertInstanceOf(
'Solarium\QueryType\Select\RequestBuilder\Component\MoreLikeThis', 'Solarium\Component\RequestBuilder\MoreLikeThis',
$this->mlt->getRequestBuilder() $this->mlt->getRequestBuilder()
); );
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
namespace Solarium\Tests\QueryType\Select\Query\Component; namespace Solarium\Tests\QueryType\Select\Query\Component;
use Solarium\QueryType\Select\Query\Component\Spatial; use Solarium\Component\Spatial;
use Solarium\QueryType\Select\Query\Query; use Solarium\QueryType\Select\Query\Query;
class SpatialTest extends \PHPUnit_Framework_TestCase class SpatialTest extends \PHPUnit_Framework_TestCase
...@@ -48,7 +48,7 @@ class SpatialTest extends \PHPUnit_Framework_TestCase ...@@ -48,7 +48,7 @@ class SpatialTest extends \PHPUnit_Framework_TestCase
public function testGetRequestBuilder() public function testGetRequestBuilder()
{ {
$this->assertInstanceOf( $this->assertInstanceOf(
'Solarium\QueryType\Select\RequestBuilder\Component\Spatial', 'Solarium\Component\RequestBuilder\Spatial',
$this->spatial->getRequestBuilder() $this->spatial->getRequestBuilder()
); );
} }
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
namespace Solarium\Tests\QueryType\Select\Query\Component; namespace Solarium\Tests\QueryType\Select\Query\Component;
use Solarium\QueryType\Select\Query\Component\Spellcheck; use Solarium\Component\Spellcheck;
use Solarium\QueryType\Select\Query\Query; use Solarium\QueryType\Select\Query\Query;
class SpellcheckTest extends \PHPUnit_Framework_TestCase class SpellcheckTest extends \PHPUnit_Framework_TestCase
...@@ -55,7 +55,7 @@ class SpellcheckTest extends \PHPUnit_Framework_TestCase ...@@ -55,7 +55,7 @@ class SpellcheckTest extends \PHPUnit_Framework_TestCase
public function testGetResponseParser() public function testGetResponseParser()
{ {
$this->assertInstanceOf( $this->assertInstanceOf(
'Solarium\QueryType\Select\ResponseParser\Component\Spellcheck', 'Solarium\Component\ResponseParser\Spellcheck',
$this->spellCheck->getResponseParser() $this->spellCheck->getResponseParser()
); );
} }
...@@ -63,7 +63,7 @@ class SpellcheckTest extends \PHPUnit_Framework_TestCase ...@@ -63,7 +63,7 @@ class SpellcheckTest extends \PHPUnit_Framework_TestCase
public function testGetRequestBuilder() public function testGetRequestBuilder()
{ {
$this->assertInstanceOf( $this->assertInstanceOf(
'Solarium\QueryType\Select\RequestBuilder\Component\Spellcheck', 'Solarium\Component\RequestBuilder\Spellcheck',
$this->spellCheck->getRequestBuilder() $this->spellCheck->getRequestBuilder()
); );
} }
......
...@@ -31,8 +31,8 @@ ...@@ -31,8 +31,8 @@
namespace Solarium\Tests\QueryType\Select\RequestBuilder\Component; namespace Solarium\Tests\QueryType\Select\RequestBuilder\Component;
use Solarium\QueryType\Select\RequestBuilder\Component\Debug as RequestBuilder; use Solarium\Component\RequestBuilder\Debug as RequestBuilder;
use Solarium\QueryType\Select\Query\Component\Debug as Component; use Solarium\Component\Debug as Component;
use Solarium\Core\Client\Request; use Solarium\Core\Client\Request;
class DebugTest extends \PHPUnit_Framework_TestCase class DebugTest extends \PHPUnit_Framework_TestCase
......
...@@ -31,8 +31,8 @@ ...@@ -31,8 +31,8 @@
namespace Solarium\Tests\QueryType\Select\RequestBuilder\Component; namespace Solarium\Tests\QueryType\Select\RequestBuilder\Component;
use Solarium\QueryType\Select\RequestBuilder\Component\MoreLikeThis as RequestBuilder; use Solarium\Component\RequestBuilder\MoreLikeThis as RequestBuilder;
use Solarium\QueryType\Select\Query\Component\MoreLikeThis as Component; use Solarium\Component\MoreLikeThis as Component;
use Solarium\Core\Client\Request; use Solarium\Core\Client\Request;
class MoreLikeThisTest extends \PHPUnit_Framework_TestCase class MoreLikeThisTest extends \PHPUnit_Framework_TestCase
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
namespace Solarium\Tests\QueryType\Select\RequestBuilder\Component; namespace Solarium\Tests\QueryType\Select\RequestBuilder\Component;
use Solarium\QueryType\Select\RequestBuilder\Component\Spatial as RequestBuilder; use Solarium\Component\RequestBuilder\Spatial as RequestBuilder;
use Solarium\QueryType\Select\Query\Component\Spatial as Component; use Solarium\Component\Spatial as Component;
use Solarium\Core\Client\Request; use Solarium\Core\Client\Request;
class SpatialTest extends \PHPUnit_Framework_TestCase class SpatialTest extends \PHPUnit_Framework_TestCase
......
...@@ -31,8 +31,8 @@ ...@@ -31,8 +31,8 @@
namespace Solarium\Tests\QueryType\Select\RequestBuilder\Component; namespace Solarium\Tests\QueryType\Select\RequestBuilder\Component;
use Solarium\QueryType\Select\RequestBuilder\Component\Spellcheck as RequestBuilder; use Solarium\Component\RequestBuilder\Spellcheck as RequestBuilder;
use Solarium\QueryType\Select\Query\Component\Spellcheck as Component; use Solarium\Component\Spellcheck as Component;
use Solarium\Core\Client\Request; use Solarium\Core\Client\Request;
class SpellcheckTest extends \PHPUnit_Framework_TestCase class SpellcheckTest extends \PHPUnit_Framework_TestCase
......
...@@ -35,7 +35,7 @@ use Solarium\Core\Client\Request; ...@@ -35,7 +35,7 @@ use Solarium\Core\Client\Request;
use Solarium\QueryType\Select\Query\Query; use Solarium\QueryType\Select\Query\Query;
use Solarium\QueryType\Select\Query\FilterQuery; use Solarium\QueryType\Select\Query\FilterQuery;
use Solarium\QueryType\Select\RequestBuilder\RequestBuilder as RequestBuilder; use Solarium\QueryType\Select\RequestBuilder\RequestBuilder as RequestBuilder;
use Solarium\QueryType\Select\Query\Component\AbstractComponent; use Solarium\Component\AbstractComponent;
class RequestBuilderTest extends \PHPUnit_Framework_TestCase class RequestBuilderTest extends \PHPUnit_Framework_TestCase
{ {
......
...@@ -31,8 +31,8 @@ ...@@ -31,8 +31,8 @@
namespace Solarium\Tests\QueryType\Select\ResponseParser\Component; namespace Solarium\Tests\QueryType\Select\ResponseParser\Component;
use Solarium\QueryType\Select\ResponseParser\Component\Debug as Parser; use Solarium\Component\ResponseParser\Debug as Parser;
use Solarium\QueryType\Select\Result\Debug\Detail; use Solarium\Component\Result\Debug\Detail;
class DebugTest extends \PHPUnit_Framework_TestCase class DebugTest extends \PHPUnit_Framework_TestCase
{ {
......
...@@ -31,10 +31,10 @@ ...@@ -31,10 +31,10 @@
namespace Solarium\Tests\QueryType\Select\ResponseParser\Component; namespace Solarium\Tests\QueryType\Select\ResponseParser\Component;
use Solarium\QueryType\Select\ResponseParser\Component\MoreLikeThis as Parser; use Solarium\Component\ResponseParser\MoreLikeThis as Parser;
use Solarium\QueryType\Select\Query\Query; use Solarium\QueryType\Select\Query\Query;
use Solarium\QueryType\Select\Result\Document; use Solarium\QueryType\Select\Result\Document;
use Solarium\QueryType\Select\Result\MoreLikeThis\Result; use Solarium\Component\Result\MoreLikeThis\Result;
class MoreLikeThisTest extends \PHPUnit_Framework_TestCase class MoreLikeThisTest extends \PHPUnit_Framework_TestCase
{ {
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
namespace Solarium\Tests\QueryType\Select\ResponseParser\Component; namespace Solarium\Tests\QueryType\Select\ResponseParser\Component;
use Solarium\QueryType\Select\ResponseParser\Component\Spellcheck as Parser; use Solarium\Component\ResponseParser\Spellcheck as Parser;
use Solarium\QueryType\Select\Query\Query; use Solarium\QueryType\Select\Query\Query;
class SpellcheckTest extends \PHPUnit_Framework_TestCase class SpellcheckTest extends \PHPUnit_Framework_TestCase
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment