Skip to content

Commit

Permalink
OPENEUROPA-1917: Temp commit #7.
Browse files Browse the repository at this point in the history
  • Loading branch information
brummbar committed Aug 22, 2019
1 parent 4a3c075 commit 8743fda
Show file tree
Hide file tree
Showing 9 changed files with 880 additions and 17 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"drupal/search_api_solr": "^3.3",
"http-interop/http-factory-guzzle": "^1.0",
"symfony/property-access": "^4.3",
"symfony/property-info": "^4.3",
"symfony/serializer": "^3.4"
},
"require-dev": {
Expand Down
6 changes: 5 additions & 1 deletion lib/src/Api/ApiBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
use OpenEuropa\EnterpriseSearchClient\ClientInterface;
use Psr\Http\Message\StreamInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor;
use Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor;
use Symfony\Component\Serializer\Encoder\JsonEncoder;
use Symfony\Component\Serializer\Normalizer\ArrayDenormalizer;
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
use Symfony\Component\Serializer\Serializer;
use Symfony\Component\Serializer\SerializerInterface;
Expand Down Expand Up @@ -151,7 +154,8 @@ protected function getMultipartStream(array $elements): StreamInterface {
protected function getSerializer(): SerializerInterface {
if ($this->serializer === NULL) {
$this->serializer = new Serializer([
new ObjectNormalizer(),
new ObjectNormalizer(null, null, null, new PhpDocExtractor()),
new ArrayDenormalizer(),
], [
new JsonEncoder(),
]);
Expand Down
8 changes: 7 additions & 1 deletion lib/src/Api/SearchApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

namespace OpenEuropa\EnterpriseSearchClient\Api;

use OpenEuropa\EnterpriseSearchClient\Model\Search;
use Symfony\Component\OptionsResolver\OptionsResolver;

class SearchApi extends ApiBase {

public function search(array $parameters = []) {
public function search(array $parameters = []): Search {
$resolver = $this->getOptionResolver();

$resolver->setRequired('text')
Expand All @@ -21,6 +22,11 @@ public function search(array $parameters = []) {
$queryParameters = array_intersect_key($parameters, $queryKeys);
$bodyParameters = array_diff_key($parameters, $queryKeys);
$response = $this->send('POST', 'rest/search', $queryParameters, $bodyParameters, true);

/** @var Search $search */
$search = $this->getSerializer()->deserialize((string) $response->getBody(), Search::class, 'json');

return $search;
}

/**
Expand Down
Loading

0 comments on commit 8743fda

Please sign in to comment.