forked from solariumphp/solarium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a801ec9
Showing
46 changed files
with
5,292 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
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 list | ||
of 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Solarium is a PHP Solr client that not only facilitates Solr communication but | ||
also tries to accurately model Solr concepts. | ||
|
||
For Docs, License, Issues, and pre-packed downloads, see: | ||
http://github.com/basdenooijer/solarium | ||
|
||
Contributors: | ||
http://github.com/basdenooijer/solarium/contributors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<project name="solarium" default="build" basedir="."> | ||
<target name="clean"> | ||
<!-- Clean up --> | ||
<delete dir="build"/> | ||
|
||
<!-- Create build directories --> | ||
<mkdir dir="${basedir}/build/api"/> | ||
<mkdir dir="${basedir}/build/code-browser"/> | ||
<mkdir dir="${basedir}/build/coverage"/> | ||
<mkdir dir="${basedir}/build/logs"/> | ||
<mkdir dir="${basedir}/build/pdepend"/> | ||
</target> | ||
|
||
<!-- Run unit tests and generate junit.xml and clover.xml | ||
(This is done in the phpunit.xml.dist, | ||
you could also write the switches here) | ||
--> | ||
<target name="phpunit"> | ||
<exec executable="phpunit" failonerror="true" /> | ||
</target> | ||
|
||
<!-- Run pdepend, phpmd, phpcpd, and phpcs in parallel --> | ||
<target name="parallelTasks"> | ||
<parallel> | ||
<antcall target="pdepend"/> | ||
<antcall target="phpmd"/> | ||
<antcall target="phpcpd"/> | ||
<antcall target="phpcs"/> | ||
<antcall target="phpdoc"/> | ||
</parallel> | ||
</target> | ||
|
||
<!-- Generate jdepend.xml and software metrics charts --> | ||
<target name="pdepend"> | ||
<exec executable="pdepend"> | ||
<arg line="--jdepend-xml=${basedir}/build/logs/jdepend.xml libraru" /> | ||
</exec> | ||
</target> | ||
|
||
<!-- Generate pmd.xml --> | ||
<target name="phpmd"> | ||
<exec executable="phpmd"> | ||
<arg line="library xml codesize,unusedcode --reportfile ${basedir}/build/logs/pmd.xml" /> | ||
</exec> | ||
</target> | ||
|
||
<!-- Generate pmd-cpd.xml --> | ||
<target name="phpcpd"> | ||
<exec executable="phpcpd"> | ||
<arg line="--log-pmd ${basedir}/build/logs/pmd-cpd.xml library" /> | ||
</exec> | ||
</target> | ||
|
||
<!-- Generate checkstyle.xml --> | ||
<target name="phpcs"> | ||
<exec executable="phpcs" output="/dev/null"> | ||
<arg line="--report=checkstyle --report-file=${basedir}/build/logs/checkstyle.xml --standard=Zend library" /> | ||
</exec> | ||
</target> | ||
|
||
<!-- Generate API documentation --> | ||
<target name="phpdoc"> | ||
<exec executable="phpdoc"> | ||
<arg line="-d library -t build/api" /> | ||
</exec> | ||
</target> | ||
|
||
<target name="phpcb"> | ||
<exec executable="phpcb"> | ||
<arg line="--log ${basedir}/build/logs --source ${basedir}/library --output ${basedir}/build/code-browser" /> | ||
</exec> | ||
</target> | ||
|
||
<target name="build" depends="clean,phpunit,parallelTasks,phpcb"/> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,242 @@ | ||
<?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. | ||
*/ | ||
|
||
/** | ||
* The Solarium Client is the main accesspoint for interaction with Solr | ||
*/ | ||
class Solarium_Client extends Solarium_Configurable | ||
{ | ||
|
||
/** | ||
* Default options | ||
* | ||
* @var array | ||
*/ | ||
protected $_options = array( | ||
'host' => '127.0.0.1', | ||
'port' => 80, | ||
'path' => '/solr', | ||
'core' => null, | ||
'adapter' => 'Solarium_Client_Adapter_Stream', | ||
); | ||
|
||
/** | ||
* Adapter instance | ||
* | ||
* @var Solarium_Client_Adapter | ||
*/ | ||
protected $_adapter; | ||
|
||
/** | ||
* Init options array. Some options might need some extra checks or setup | ||
* work. | ||
* | ||
* @return void | ||
*/ | ||
protected function _init() | ||
{ | ||
foreach ($this->_options AS $name => $value) { | ||
switch ($name) { | ||
case 'path': | ||
$this->setPath($value); | ||
break; | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Set an option | ||
* | ||
* @param string $name | ||
* @param mixed $value | ||
* @return void | ||
*/ | ||
protected function _setOption($name, $value) | ||
{ | ||
parent::_setOption($name, $value); | ||
|
||
if (null !== $this->_adapter) { | ||
$this->_adapter->setOptions($this->_options); | ||
} | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* Set host option | ||
* | ||
* @param string $host | ||
* @return Solarium_Client Provides fluent interface | ||
*/ | ||
public function setHost($host) | ||
{ | ||
return $this->_setOption('host', $host); | ||
} | ||
|
||
/** | ||
* Get host option | ||
* | ||
* @return string | ||
*/ | ||
public function getHost() | ||
{ | ||
return $this->getOption('host'); | ||
} | ||
|
||
/** | ||
* Set port option | ||
* | ||
* @param int $port | ||
* @return Solarium_Client Provides fluent interface | ||
*/ | ||
public function setPort($port) | ||
{ | ||
return $this->_setOption('port', $port); | ||
} | ||
|
||
/** | ||
* Get port option | ||
* @return int | ||
*/ | ||
public function getPort() | ||
{ | ||
return $this->getOption('port'); | ||
} | ||
|
||
/** | ||
* Set path option | ||
* | ||
* @param string $path | ||
* @return Solarium_Client Provides fluent interface | ||
*/ | ||
public function setPath($path) | ||
{ | ||
// remove trailing slashes | ||
if (substr($path, -1) == '/') $path = substr($path, 0, -1); | ||
|
||
return $this->_setOption('path', $path); | ||
} | ||
|
||
/** | ||
* Get path option | ||
* | ||
* @return void | ||
*/ | ||
public function getPath() | ||
{ | ||
return $this->getOption('path'); | ||
} | ||
|
||
/** | ||
* Set core option | ||
* | ||
* @param string $core | ||
* @return Solarium_Client Provides fluent interface | ||
*/ | ||
public function setCore($core) | ||
{ | ||
return $this->_setOption('core', $core); | ||
} | ||
|
||
/** | ||
* Get core option | ||
* | ||
* @return string | ||
*/ | ||
public function getCore() | ||
{ | ||
return $this->getOption('core'); | ||
} | ||
|
||
/** | ||
* Set the adapter | ||
* | ||
* @param string|Solarium_Client_Adapter $adapter | ||
* @return Solarium_Client Provides fluent interface | ||
*/ | ||
public function setAdapter($adapter) | ||
{ | ||
if (is_string($adapter)) { | ||
$adapter = new $adapter; | ||
} | ||
|
||
$adapter->setOptions($this->_options); | ||
$this->_adapter = $adapter; | ||
return $this; | ||
} | ||
|
||
/** | ||
* Get the adapter instance | ||
* | ||
* @return Solarium_Client_Adapter | ||
*/ | ||
public function getAdapter() | ||
{ | ||
if (null === $this->_adapter) { | ||
$this->setAdapter($this->_options['adapter']); | ||
} | ||
|
||
return $this->_adapter; | ||
} | ||
|
||
/** | ||
* Execute a ping query | ||
* | ||
* @param Solarium_Query_Ping $query | ||
* @return Solarium_Result_Ping | ||
*/ | ||
public function ping($query) | ||
{ | ||
return $this->getAdapter()->ping($query); | ||
} | ||
|
||
/** | ||
* Execute an update query | ||
* | ||
* @param Solarium_Query_Update $query | ||
* @return Solarium_Result_Select | ||
*/ | ||
public function update($query) | ||
{ | ||
return $this->getAdapter()->update($query); | ||
} | ||
|
||
/** | ||
* Execute a select query | ||
* | ||
* @param Solarium_Query_Select $query | ||
* @return Solarium_Result_Select | ||
*/ | ||
public function select($query) | ||
{ | ||
return $this->getAdapter()->select($query); | ||
} | ||
} |
Oops, something went wrong.