From cf8f24c9b9214b6096fe262ce23834dfcfe09dad Mon Sep 17 00:00:00 2001 From: Elliot Sawyer Date: Wed, 11 Jul 2018 15:19:11 +1200 Subject: [PATCH] Split Service and Service_Core classes into separate files --- code/solr/Solr3Service.php | 5 ---- code/solr/Solr3Service_Core.php | 4 +++ code/solr/Solr4Service.php | 53 --------------------------------- code/solr/Solr4Service_Core.php | 52 ++++++++++++++++++++++++++++++++ code/solr/Solr5Service.php | 6 ---- code/solr/Solr5Service_Core.php | 5 ++++ 6 files changed, 61 insertions(+), 64 deletions(-) create mode 100644 code/solr/Solr3Service_Core.php create mode 100644 code/solr/Solr4Service_Core.php create mode 100644 code/solr/Solr5Service_Core.php diff --git a/code/solr/Solr3Service.php b/code/solr/Solr3Service.php index 6c3e535..169e731 100644 --- a/code/solr/Solr3Service.php +++ b/code/solr/Solr3Service.php @@ -1,9 +1,4 @@ '; - 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 = ""; - foreach ($documents as $document) { - if ($document instanceof Apache_Solr_Document) { - $rawPost .= $this->_documentToXmlFragment($document); - } - } - $rawPost .= ''; - - return $this->add($rawPost); - } -} - class Solr4Service extends SolrService { private static $core_class = 'Solr4Service_Core'; diff --git a/code/solr/Solr4Service_Core.php b/code/solr/Solr4Service_Core.php new file mode 100644 index 0000000..7b8d002 --- /dev/null +++ b/code/solr/Solr4Service_Core.php @@ -0,0 +1,52 @@ +'; + 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 = ""; + foreach ($documents as $document) { + if ($document instanceof Apache_Solr_Document) { + $rawPost .= $this->_documentToXmlFragment($document); + } + } + $rawPost .= ''; + + return $this->add($rawPost); + } +} diff --git a/code/solr/Solr5Service.php b/code/solr/Solr5Service.php index eef5962..00f9927 100644 --- a/code/solr/Solr5Service.php +++ b/code/solr/Solr5Service.php @@ -1,10 +1,4 @@