Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
dbp-relay-base-bundle
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
digital blueprint
Relay API Gateway
dbp-relay-base-bundle
Commits
6b9b080c
Unverified
Commit
6b9b080c
authored
3 years ago
by
Patrizio Bekerle
Browse files
Options
Downloads
Patches
Plain Diff
Add PersonProviderInterface documentation
parent
d80e30c4
No related branches found
Branches containing commit
Tags
v0.1.14
Tags containing commit
No related merge requests found
Pipeline
#58108
passed with warnings
3 years ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
README.md
+85
-0
85 additions, 0 deletions
README.md
src/API/PersonProviderInterface.php
+8
-0
8 additions, 0 deletions
src/API/PersonProviderInterface.php
with
93 additions
and
0 deletions
README.md
+
85
−
0
View file @
6b9b080c
...
@@ -23,3 +23,88 @@ Dbp\Relay\CoreBundle\DbpRelayCoreBundle => ['all' => true],
...
@@ -23,3 +23,88 @@ Dbp\Relay\CoreBundle\DbpRelayCoreBundle => ['all' => true],
*
Run
`composer install`
to clear caches
*
Run
`composer install`
to clear caches
## PersonProvider service
For this bundle to work you need to create a service that implements
[
PersonProviderInterface
](
https://gitlab.tugraz.at/dbp/relay/dbp-relay-base-bundle/-/blob/main/src/API/PersonProviderInterface.php
)
in your application.
### Example
#### Service class
You can for example put below code into
`src/Service/PersonProvider.php`
:
```
php
<?php
declare
(
strict_types
=
1
);
namespace
YourUniversity\Service
;
use
Dbp\Relay\BaseBundle\API\PersonProviderInterface
;
use
Dbp\Relay\BaseBundle\Entity\Person
;
use
Symfony\Component\HttpKernel\Exception\BadRequestHttpException
;
class
PersonProvider
implements
PersonProviderInterface
{
/**
* @param array $filters $filters['search'] can be a string to search for people (e.g. part of the name)
* @return Person[]
*/
public
function
getPersons
(
array
$filters
):
array
{
$people
=
some_method_to_fetch_persons
(
$filters
);
return
$people
;
}
public
function
getPersonsByNameAndBirthDate
(
string
$givenName
,
string
$familyName
,
string
$birthDate
):
array
{
$people
=
some_method_to_fetch_persons_by_name_and_birthday
(
$givenName
,
$familyName
,
$birthDate
);
return
$people
;
}
public
function
getPerson
(
string
$id
):
Person
{
return
some_method_to_fetch_person_by_id
(
$id
);
}
/**
* This is only used by external services (e.g. the alma bundle) to translate external persons to internal persons
*
* @param string $service identifies the service that wants to fetch a person
* @param string $serviceID identifies person by an external id
* @return Person
*/
public
function
getPersonForExternalService
(
string
$service
,
string
$serviceID
):
Person
{
switch
(
$service
)
{
case
"some-service"
:
return
some_method_to_fetch_person_from_external_service
(
$serviceID
);
break
;
default
:
throw
new
BadRequestHttpException
(
"Unknown service:
$service
"
);
}
}
/**
* Returns the Person matching the current user. Or null if there is no associated person
* like when the client is another server.
*/
public
function
getCurrentPerson
():
?Person
{
return
some_method_to_fetch_current_person
();
}
}
```
#### Services configuration
For above class you need to add this to your
`src/Resources/config/services.yaml`
:
```
yaml
Dbp\Relay\BaseBundle\API\PersonProviderInterface
:
'
@YourUniversity\Service\PersonProvider'
```
This diff is collapsed.
Click to expand it.
src/API/PersonProviderInterface.php
+
8
−
0
View file @
6b9b080c
...
@@ -9,6 +9,7 @@ use Dbp\Relay\BaseBundle\Entity\Person;
...
@@ -9,6 +9,7 @@ use Dbp\Relay\BaseBundle\Entity\Person;
interface
PersonProviderInterface
interface
PersonProviderInterface
{
{
/**
/**
* @param array $filters $filters['search'] can be a string to search for people (e.g. part of the name)
* @return Person[]
* @return Person[]
*/
*/
public
function
getPersons
(
array
$filters
):
array
;
public
function
getPersons
(
array
$filters
):
array
;
...
@@ -20,6 +21,13 @@ interface PersonProviderInterface
...
@@ -20,6 +21,13 @@ interface PersonProviderInterface
public
function
getPerson
(
string
$id
):
Person
;
public
function
getPerson
(
string
$id
):
Person
;
/**
* This is only used by external services (e.g. the alma bundle) to translate external persons to internal persons
*
* @param string $service identifies the service that wants to fetch a person
* @param string $serviceID identifies person by an external id
* @return Person
*/
public
function
getPersonForExternalService
(
string
$service
,
string
$serviceID
):
Person
;
public
function
getPersonForExternalService
(
string
$service
,
string
$serviceID
):
Person
;
/**
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment