mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 22:53:49 +00:00
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:
@@ -34,6 +34,7 @@ class ChillThirdPartyExtension extends Extension implements PrependExtensionInte
|
||||
$loader->load('services/templating.yaml');
|
||||
$loader->load('services/menu.yaml');
|
||||
$loader->load('services/fixtures.yaml');
|
||||
$loader->load('services/serializer.yaml');
|
||||
}
|
||||
|
||||
public function prepend(ContainerBuilder $container)
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
@@ -1,5 +1,2 @@
|
||||
---
|
||||
services:
|
||||
Chill\ThirdPartyBundle\DataFixtures\ORM\LoadThirdParty:
|
||||
tags:
|
||||
- { 'name': doctrine.fixture.orm }
|
||||
|
@@ -0,0 +1,5 @@
|
||||
---
|
||||
services:
|
||||
Chill\ThirdPartyBundle\DataFixtures\ORM\LoadThirdParty:
|
||||
tags:
|
||||
- { 'name': doctrine.fixture.orm }
|
||||
|
@@ -0,0 +1,5 @@
|
||||
services:
|
||||
Chill\ThirdPartyBundle\Serializer\Normalizer\:
|
||||
resource: '../../Serializer/Normalizer/'
|
||||
tags:
|
||||
- { name: 'serializer.normalizer', priority: 64 }
|
Reference in New Issue
Block a user