From c92db122be772da88cd8a571912d04d3e893ab4a Mon Sep 17 00:00:00 2001 From: Patrizio Bekerle <patrizio@bekerle.com> Date: Thu, 21 Oct 2021 10:58:17 +0200 Subject: [PATCH] Add OrganizationProviderInterface documentation --- README.md | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/README.md b/README.md index 57f5fd1..33bfe5b 100644 --- a/README.md +++ b/README.md @@ -108,3 +108,59 @@ For above class you need to add this to your `src/Resources/config/services.yaml Dbp\Relay\BaseBundle\API\PersonProviderInterface: '@YourUniversity\Service\PersonProvider' ``` + +## OrganizationProvider service + +For services that need to fetch organizations you need to create a service that implements +[OrganizationProviderInterface](https://gitlab.tugraz.at/dbp/relay/dbp-relay-base-bundle/-/blob/main/src/API/OrganizationProviderInterface.php) +in your application. + +### Example + +#### Service class + +You can for example put below code into `src/Service/OrganizationProvider.php`: + +```php +<?php + +declare(strict_types=1); + +namespace YourUniversity\Service; + +use Dbp\Relay\BaseBundle\API\OrganizationProviderInterface; +use Dbp\Relay\BaseBundle\Entity\Organization; + +class OrganizationProvider implements OrganizationProviderInterface +{ + public function getOrganizationById(string $identifier, string $lang): Organization + { + return some_method_that_fetches_an_organization_by_id($identifier, $lang); + } + + /** + * @return Organization[] + */ + public function getOrganizationsByPerson(Person $person, string $context, string $lang): array + { + return some_method_that_fetches_an_organization_by_person($person, $context, $lang); + } + + /** + * @return Organization[] + */ + public function getOrganizations(string $lang): array + { + return some_method_that_fetches_all_organizations($lang); + } +} +``` + +#### Services configuration + +For above class you need to add this to your `src/Resources/config/services.yaml`: + +```yaml + Dbp\Relay\BaseBundle\API\OrganizationProviderInterface: + '@YourUniversity\Service\OrganizationProvider' +``` -- GitLab