Skip to content

Commit

Permalink
Merge pull request #125 from Wikidata-lib/api
Browse files Browse the repository at this point in the history
Adjust api code for core api changes
  • Loading branch information
mariushoch committed Apr 24, 2015
2 parents 58140c0 + 2054dd3 commit 0bebf90
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
18 changes: 14 additions & 4 deletions src/PropertySuggester/GetSuggestions.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use ApiBase;
use ApiMain;
use ApiResult;
use DerivativeRequest;
use PropertySuggester\Suggesters\SimpleSuggester;
use PropertySuggester\Suggesters\SuggesterEngine;
Expand Down Expand Up @@ -101,7 +102,7 @@ public function execute() {

// Define Result
$slicedEntries = array_slice( $entries, $params->continue, $params->limit );
$this->getResult()->setIndexedTagName( $slicedEntries, 'search' );
ApiResult::setIndexedTagName( $slicedEntries, 'search' );
$this->getResult()->addValue( null, 'search', $slicedEntries );

$this->getResult()->addValue( null, 'success', 1 );
Expand Down Expand Up @@ -130,11 +131,20 @@ private function querySearchApi( $resultSize, $search, $language ) {
'type' => Property::ENTITY_TYPE
)
);

$api = new ApiMain( $searchEntitiesParameters );
$api->execute();
$apiResult = $api->getResultData();
$searchResult = $apiResult['search'];
return $searchResult;

$apiResult = $api->getResult()->getResultData(
null,
array(
'BC' => array(),
'Types' => array(),
'Strip' => 'all'
)
);

return $apiResult['search'];
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/PropertySuggester/ResultBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ private function checkAndSetAlias( array &$entry, Term $term ) {
if ( preg_match( $this->searchPattern, $term->getText() ) ) {
if ( !isset( $entry['aliases'] ) ) {
$entry['aliases'] = array();
$this->result->setIndexedTagName( $entry['aliases'], 'alias' );
ApiResult::setIndexedTagName( $entry['aliases'], 'alias' );
}
$entry['aliases'][] = $term->getText();
}
Expand Down
3 changes: 1 addition & 2 deletions tests/phpunit/PropertySuggester/ResultBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ class ResultBuilderTest extends MediaWikiTestCase {

public function setUp() {
parent::setUp();
$apiMain = $this->getMockBuilder( 'ApiMain' )->disableOriginalConstructor()->getMockForAbstractClass();

$entityTitleLookup = $this->getMock( 'Wikibase\Lib\Store\EntityTitleLookup' );
$termIndex = $this->getMock( 'Wikibase\TermIndex' );
$result = new ApiResult( $apiMain );
$result = new ApiResult( false ); // $maxSize, no limit

$this->resultBuilder = new ResultBuilder( $result, $termIndex, $entityTitleLookup, '' );
}
Expand Down

0 comments on commit 0bebf90

Please sign in to comment.