mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
fix conflict
This commit is contained in:
@@ -28,17 +28,39 @@ use function array_values;
|
||||
class PersonApiController extends ApiController
|
||||
{
|
||||
private AuthorizationHelper $authorizationHelper;
|
||||
|
||||
private ConfigPersonAltNamesHelper $configPersonAltNameHelper;
|
||||
|
||||
public function __construct(
|
||||
AuthorizationHelper $authorizationHelper,
|
||||
ConfigPersonAltNamesHelper $configPersonAltNameHelper
|
||||
)
|
||||
{
|
||||
) {
|
||||
$this->authorizationHelper = $authorizationHelper;
|
||||
$this->configPersonAltNameHelper = $configPersonAltNameHelper;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/api/1.0/person/config/alt_names.{_format}",
|
||||
* name="chill_person_config_alt_names",
|
||||
* requirements={
|
||||
* "_format": "json"
|
||||
* }
|
||||
* )
|
||||
*/
|
||||
public function configAltNames(Request $request, string $_format): Response
|
||||
{
|
||||
$configAltNamesChoices = $this->configPersonAltNameHelper->getChoices();
|
||||
|
||||
return $this->json(
|
||||
array_map(
|
||||
static fn (array $data, string $key): array => ['key' => $key, 'labels' => $data],
|
||||
$configAltNamesChoices,
|
||||
array_keys($configAltNamesChoices)
|
||||
),
|
||||
Response::HTTP_OK, [], ['groups' => ['read']]
|
||||
);
|
||||
}
|
||||
|
||||
public function personAddressApi($id, Request $request, string $_format): Response
|
||||
{
|
||||
return $this->addRemoveSomething('address', $id, $request, $_format, 'address', Address::class, ['groups' => ['read']]);
|
||||
@@ -76,27 +98,4 @@ class PersonApiController extends ApiController
|
||||
return $this->json(array_values($addresses), Response::HTTP_OK, [], ['groups' => ['read']]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @Route("/api/1.0/person/config/alt_names.{_format}",
|
||||
* name="chill_person_config_alt_names",
|
||||
* requirements={
|
||||
* "_format": "json"
|
||||
* }
|
||||
* )
|
||||
*/
|
||||
public function configAltNames(Request $request, string $_format): Response
|
||||
{
|
||||
$configAltNamesChoices = $this->configPersonAltNameHelper->getChoices();
|
||||
|
||||
return $this->json(
|
||||
array_map(
|
||||
static fn (array $data, string $key): array => ['key' => $key, 'labels' => $data],
|
||||
$configAltNamesChoices,
|
||||
array_keys($configAltNamesChoices)
|
||||
),
|
||||
Response::HTTP_OK, [], ['groups' => ['read']]
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -80,7 +80,7 @@ class PersonJsonNormalizer implements
|
||||
}
|
||||
|
||||
foreach (['firstName', 'lastName', 'phonenumber', 'mobilenumber', 'gender',
|
||||
'birthdate', 'deathdate', 'center', 'altNames']
|
||||
'birthdate', 'deathdate', 'center', 'altNames', ]
|
||||
as $item) {
|
||||
if (!array_key_exists($item, $data)) {
|
||||
continue;
|
||||
@@ -133,8 +133,11 @@ class PersonJsonNormalizer implements
|
||||
break;
|
||||
|
||||
case 'altNames':
|
||||
foreach($data[$item] as $altName){
|
||||
$oldAltName = $person->getAltNames()->filter(function (PersonAltName $n) use ($altName) { return $n->getKey() === $altName['key']; })->first();
|
||||
foreach ($data[$item] as $altName) {
|
||||
$oldAltName = $person
|
||||
->getAltNames()
|
||||
->filter(static fn (PersonAltName $n): bool => $n->getKey() === $altName['key'])->first();
|
||||
|
||||
if (false === $oldAltName) {
|
||||
$newAltName = new PersonAltName();
|
||||
$newAltName->setKey($altName['key']);
|
||||
@@ -144,6 +147,7 @@ class PersonJsonNormalizer implements
|
||||
$oldAltName->setLabel($altName['label']);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@@ -12,6 +12,7 @@ declare(strict_types=1);
|
||||
namespace Chill\PersonBundle\Tests\Form\Type;
|
||||
|
||||
use Chill\PersonBundle\Form\Type\PickPersonType;
|
||||
use RuntimeException;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
|
||||
use function count;
|
||||
@@ -52,7 +53,7 @@ final class PickPersonTypeTest extends KernelTestCase
|
||||
*/
|
||||
public function testWithInvalidOptionCenters()
|
||||
{
|
||||
$this->expectException(\RuntimeException::class);
|
||||
$this->expectException(RuntimeException::class);
|
||||
|
||||
$this->markTestSkipped('need to inject locale into url generator without request');
|
||||
$this->formFactory
|
||||
|
Reference in New Issue
Block a user