/** * {@inheritdoc} * * Sets the HMAC authentication plugin, sets the base_path to point to the * correct index. */ public static function factory($config = array()) { // We just use this for validation. The configs are set in the parent's // factory methid. Collection::fromConfig($config, array(), array('index_id', 'derived_key')); $solr = parent::factory($config); // Get the configs relevant to Acquia Search. $indexId = $solr->getConfig('index_id'); $derivedKey = $solr->getConfig('derived_key'); // Set the base bath to point to the configured index. $solr->getConfig()->set('base_path', '/solr/' . $indexId); // Attach the Acquia Search HMAC Authentication plugin to the client. $signature = new Signature($derivedKey); $plugin = new AcquiaSearchAuthPlugin($indexId, $signature); $solr->addSubscriber($plugin); return $solr; }
/** * @param \PSolr\Request\SolrClient $solr * @param array|null $headers * @param array $options * * @return \PSolr\Response\Response|\SimpleXMLElement * * @throws \UnexpectedValueException */ public function sendRequest(SolrClient $solr, $headers = null, array $options = array()) { // If we don't have a request handler, then the passed request is only a // component and we cannot execute the search. if (null === $this->handlerName) { throw new \UnexpectedValueException('Unable to send request: handler name missing'); } // @todo Add a method in \PSolr\Response\Response to normalize the XML // in to an array. Just use JSON and all is right in the world. $params = $this->toArray(); $data = $solr->sendRequest($this->handlerName, $params, $this->renderBody(), $headers, $options); return is_array($data) ? new $this->responseClass($data, $params) : $data; }
public function testPing() { $solr = SolrClient::factory(); $response = $solr->ping(); $this->assertEquals(array(), $response); }