Split Service and Service_Core classes into separate files

This commit is contained in:
Elliot Sawyer 2018-07-11 15:19:11 +12:00
parent 307c5a1c75
commit cf8f24c9b9
6 changed files with 61 additions and 64 deletions

View File

@ -1,9 +1,4 @@
<?php
class Solr3Service_Core extends SolrService_Core
{
}
class Solr3Service extends SolrService
{
private static $core_class = 'Solr3Service_Core';

View File

@ -0,0 +1,4 @@
<?php
class Solr3Service_Core extends SolrService_Core
{
}

View File

@ -1,57 +1,4 @@
<?php
class Solr4Service_Core extends SolrService_Core
{
/**
* Replace underlying commit function to remove waitFlush in 4.0+, since it's been deprecated and 4.4 throws errors
* if you pass it
*/
public function commit($expungeDeletes = false, $waitFlush = null, $waitSearcher = true, $timeout = 3600)
{
if ($waitFlush) {
user_error('waitFlush must be false when using Solr 4.0+' . E_USER_ERROR);
}
$expungeValue = $expungeDeletes ? 'true' : 'false';
$searcherValue = $waitSearcher ? 'true' : 'false';
$rawPost = '<commit expungeDeletes="' . $expungeValue . '" waitSearcher="' . $searcherValue . '" />';
return $this->_sendRawPost($this->_updateUrl, $rawPost, $timeout);
}
/**
* @inheritdoc
* @see Solr4Service_Core::addDocuments
*/
public function addDocument(Apache_Solr_Document $document, $allowDups = false,
$overwritePending = true, $overwriteCommitted = true, $commitWithin = 0
) {
return $this->addDocuments(array($document), $allowDups, $overwritePending, $overwriteCommitted, $commitWithin);
}
/**
* Solr 4.0 compat http://wiki.apache.org/solr/UpdateXmlMessages#Optional_attributes_for_.22add.22
* Remove allowDups, overwritePending and overwriteComitted
*/
public function addDocuments($documents, $allowDups = false, $overwritePending = true,
$overwriteCommitted = true, $commitWithin = 0
) {
$overwriteVal = $allowDups ? 'false' : 'true';
$commitWithin = (int) $commitWithin;
$commitWithinString = $commitWithin > 0 ? " commitWithin=\"{$commitWithin}\"" : '';
$rawPost = "<add overwrite=\"{$overwriteVal}\"{$commitWithinString}>";
foreach ($documents as $document) {
if ($document instanceof Apache_Solr_Document) {
$rawPost .= $this->_documentToXmlFragment($document);
}
}
$rawPost .= '</add>';
return $this->add($rawPost);
}
}
class Solr4Service extends SolrService
{
private static $core_class = 'Solr4Service_Core';

View File

@ -0,0 +1,52 @@
<?php
class Solr4Service_Core extends SolrService_Core
{
/**
* Replace underlying commit function to remove waitFlush in 4.0+, since it's been deprecated and 4.4 throws errors
* if you pass it
*/
public function commit($expungeDeletes = false, $waitFlush = null, $waitSearcher = true, $timeout = 3600)
{
if ($waitFlush) {
user_error('waitFlush must be false when using Solr 4.0+' . E_USER_ERROR);
}
$expungeValue = $expungeDeletes ? 'true' : 'false';
$searcherValue = $waitSearcher ? 'true' : 'false';
$rawPost = '<commit expungeDeletes="' . $expungeValue . '" waitSearcher="' . $searcherValue . '" />';
return $this->_sendRawPost($this->_updateUrl, $rawPost, $timeout);
}
/**
* @inheritdoc
* @see Solr4Service_Core::addDocuments
*/
public function addDocument(Apache_Solr_Document $document, $allowDups = false,
$overwritePending = true, $overwriteCommitted = true, $commitWithin = 0
) {
return $this->addDocuments(array($document), $allowDups, $overwritePending, $overwriteCommitted, $commitWithin);
}
/**
* Solr 4.0 compat http://wiki.apache.org/solr/UpdateXmlMessages#Optional_attributes_for_.22add.22
* Remove allowDups, overwritePending and overwriteComitted
*/
public function addDocuments($documents, $allowDups = false, $overwritePending = true,
$overwriteCommitted = true, $commitWithin = 0
) {
$overwriteVal = $allowDups ? 'false' : 'true';
$commitWithin = (int) $commitWithin;
$commitWithinString = $commitWithin > 0 ? " commitWithin=\"{$commitWithin}\"" : '';
$rawPost = "<add overwrite=\"{$overwriteVal}\"{$commitWithinString}>";
foreach ($documents as $document) {
if ($document instanceof Apache_Solr_Document) {
$rawPost .= $this->_documentToXmlFragment($document);
}
}
$rawPost .= '</add>';
return $this->add($rawPost);
}
}

View File

@ -1,10 +1,4 @@
<?php
class Solr5Service_Core extends Solr4Service_Core
{
}
class Solr5Service extends Solr4Service
{
private static $core_class = 'Solr5Service_Core';

View File

@ -0,0 +1,5 @@
<?php
class Solr5Service_Core extends Solr4Service_Core
{
}