From b0b02c6d4958a5071febecd86520fe602db9ad08 Mon Sep 17 00:00:00 2001 From: Christoph Reiter <reiter.christoph@gmail.com> Date: Tue, 2 Feb 2021 14:02:07 +0100 Subject: [PATCH] Use a dummy person provider by default --- config/services.yaml | 7 +++++ src/{ => Service}/MyCustomPersonProvider.php | 30 +++++++++++++------- 2 files changed, 27 insertions(+), 10 deletions(-) rename src/{ => Service}/MyCustomPersonProvider.php (57%) diff --git a/config/services.yaml b/config/services.yaml index e69de29..b0691b1 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -0,0 +1,7 @@ +services: + App\Service\: + resource: '../src/Service' + autowire: true + + # Replace the core one with our custom (dummy) implementation. + DBP\API\CoreBundle\Service\PersonProviderInterface: '@App\Service\MyCustomPersonProvider' \ No newline at end of file diff --git a/src/MyCustomPersonProvider.php b/src/Service/MyCustomPersonProvider.php similarity index 57% rename from src/MyCustomPersonProvider.php rename to src/Service/MyCustomPersonProvider.php index 091c42a..286580e 100644 --- a/src/MyCustomPersonProvider.php +++ b/src/Service/MyCustomPersonProvider.php @@ -2,46 +2,56 @@ declare(strict_types=1); -namespace App; +namespace App\Service; use DBP\API\CoreBundle\Entity\Person; use DBP\API\CoreBundle\Service\PersonProviderInterface; +use Symfony\Component\Security\Core\Security; class MyCustomPersonProvider implements PersonProviderInterface { + private $security; + + public function __construct(Security $security) + { + $this->security = $security; + } + public function getPersons(array $filters): array { - // TODO: Implement getPersons() method. - return []; + return [$this->getCurrentPerson()]; } public function getPersonsByNameAndBirthday(string $givenName, string $familyName, \DateTime $birthDay): array { - // TODO: Implement getPersonsByNameAndBirthday() method. return []; } public function getPerson(string $id): Person { - // TODO: Implement getPerson() method. - return new Person(); + $person = new Person(); + $person->setIdentifier($id); + $person->setGivenName('John'); + $person->setFamilyName('Doe'); + $person->setEmail('john.doe@example.com'); + + return $person; } public function getCurrentPerson(): Person { - // TODO: Implement getCurrentPerson() method. - return new Person(); + $user = $this->security->getUser(); + + return $this->getPerson($user->getUsername()); } public function getPersonForExternalService(string $service, string $serviceID): Person { - // TODO: Implement getPersonForExternalService() method. return new Person(); } public function getRolesForScopes(array $scopes): array { - // TODO: Implement getRolesForScopes() method. return []; } } -- GitLab