示例#1
0
 /**
  * @param array <string> $files
  *
  * @return array
  */
 public function load(array $files)
 {
     $update = $this->client->createUpdate();
     /** @var $loader \Nelmio\Alice\Loader\Base */
     $loader = $this->getLoader('yaml');
     $loader->setProviders($this->providers);
     foreach ($files as $file) {
         $update->addDocuments($loader->load($file));
     }
     $update->addCommit();
     if (null !== $update) {
         $this->client->execute($update);
     }
 }
 /**
  * @param Query $query
  * @param callable $transform
  * @param null $readEndpoint
  * @param null $writeEndpoint
  */
 public function updateNoBuffer(Query $query, callable $transform, $readEndpoint = null, $writeEndpoint = null, $commit = true)
 {
     $update = $this->solarium->createUpdate();
     $documents = $this->solarium->execute($query, $readEndpoint);
     foreach ($documents as $document) {
         $update->addDocument($transform($document));
     }
     if (count($documents) > 0 && $commit === true) {
         $update->addCommit();
     }
     $this->solarium->execute($update, $writeEndpoint);
 }
示例#3
0
 public function testExecuteWithOverridingPlugin()
 {
     $query = new PingQuery();
     $response = new Response('', array('HTTP 1.0 200 OK'));
     $expectedResult = new Result($this->client, $query, $response);
     $expectedEvent = new PreExecuteEvent($query);
     $expectedEvent->setDispatcher($this->client->getEventDispatcher());
     $expectedEvent->setName(Events::PRE_EXECUTE);
     $test = $this;
     $this->client->getEventDispatcher()->addListener(Events::PRE_EXECUTE, function (PreExecuteEvent $event) use($test, $expectedResult, $expectedEvent) {
         $test->assertEquals($expectedEvent, $event);
         $event->setResult($expectedResult);
     });
     $returnedResult = $this->client->execute($query);
     $this->assertEquals($expectedResult, $returnedResult);
 }