add endoint /api/1.0/search.json?q=xxx with fake data

See https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/136
This commit is contained in:
2021-05-07 19:11:10 +02:00
parent 038d7ad2e1
commit 7a1ad24f0e
16 changed files with 261 additions and 25 deletions

View File

@@ -0,0 +1,31 @@
<?php
namespace Chill\ThirdPartyBundle\Serializer\Normalizer;
use Chill\ThirdPartyBundle\Entity\ThirdParty;
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
class ThirdPartyNormalizer implements NormalizerInterface, NormalizerAwareInterface
{
use NormalizerAwareTrait;
public function normalize($thirdParty, string $format = null, array $context = [])
{
/** @var $thirdParty ThirdParty */
$data['type'] = 'thirdparty';
// TODO should be replaced by a "render entity"
$data['text'] = $thirdParty->getName();
$data['thirdparty_id'] = $thirdParty->getId();
$data['address'] = $this->normalizer->normalize($thirdParty->getAddress(), $format,
[ 'address_rendering' => 'short' ]);
return $data;
}
public function supportsNormalization($data, string $format = null)
{
return $data instanceof ThirdParty;
}
}