From c05a5f055497a49c46d0cb1c0cdeaaefff04912b Mon Sep 17 00:00:00 2001 From: Christoph Reiter <reiter.christoph@gmail.com> Date: Thu, 21 Oct 2021 14:48:13 +0200 Subject: [PATCH] Remove person code and rename to relay-base-organization-bundle --- README.md | 167 +-------- composer.json | 7 +- composer.lock | 346 ++++++++++++------ phpstan.neon | 1 - phpunit.xml.dist | 2 +- requests/.gitignore | 1 - requests/README.md | 6 - requests/get-requests.http | 13 - requests/http-client.env.json | 12 - requests/http-client.private.env.exam.json | 8 - src/API/OrganizationProviderInterface.php | 6 +- src/API/PersonProviderInterface.php | 38 -- src/Controller/GetOrganizationsByPerson.php | 6 +- .../OrganizationCollectionDataProvider.php | 6 +- src/DataProvider/OrganizationDataProvider.php | 6 +- .../PersonCollectionDataProvider.php | 54 --- src/DataProvider/PersonItemDataProvider.php | 37 -- ...php => DbpRelayBaseOrganizationBundle.php} | 4 +- src/DependencyInjection/Configuration.php | 4 +- ... => DbpRelayBaseOrganizationExtension.php} | 4 +- src/Entity/Organization.php | 10 +- src/Entity/OrganizationTrait.php | 2 +- src/Entity/Person.php | 42 --- src/Entity/PersonTrait.php | 147 -------- src/Resources/config/services.yaml | 30 +- src/Serializer/PersonAttributeNormalizer.php | 60 --- src/Service/DummyOrganizationProvider.php | 8 +- src/Service/DummyPersonProvider.php | 83 ----- src/TestUtils/DummyPersonProvider.php | 65 ---- tests/ExtTest.php | 86 +---- tests/Kernel.php | 8 +- tests/OrganizationTest.php | 4 +- tests/PersonTest.php | 30 -- 33 files changed, 292 insertions(+), 1011 deletions(-) delete mode 100644 requests/.gitignore delete mode 100644 requests/README.md delete mode 100644 requests/get-requests.http delete mode 100644 requests/http-client.env.json delete mode 100644 requests/http-client.private.env.exam.json delete mode 100644 src/API/PersonProviderInterface.php delete mode 100644 src/DataProvider/PersonCollectionDataProvider.php delete mode 100644 src/DataProvider/PersonItemDataProvider.php rename src/{DbpRelayBaseBundle.php => DbpRelayBaseOrganizationBundle.php} (69%) rename src/DependencyInjection/{DbpRelayBaseExtension.php => DbpRelayBaseOrganizationExtension.php} (89%) delete mode 100644 src/Entity/Person.php delete mode 100644 src/Entity/PersonTrait.php delete mode 100644 src/Serializer/PersonAttributeNormalizer.php delete mode 100644 src/Service/DummyPersonProvider.php delete mode 100644 src/TestUtils/DummyPersonProvider.php delete mode 100644 tests/PersonTest.php diff --git a/README.md b/README.md index 33bfe5b..12de2a7 100644 --- a/README.md +++ b/README.md @@ -1,166 +1,3 @@ -# DbpRelayBaseBundle +# DbpRelayBaseOrganizationBundle -[GitLab](https://gitlab.tugraz.at/dbp/relay/dbp-relay-base-bundle) | [Packagist](https://packagist.org/packages/dbp/relay-base-bundle) - -This Symfony bundle contains entities required by many bundles for the DBP Relay project. - -## Integration into the Relay API Server - -* Add the bundle package as a dependency: - -``` -composer require dbp/relay-base-bundle -``` - -* Add the bundle to your `config/bundles.php` in front of `DbpRelayCoreBundle`: - -```php -... -Dbp\Relay\BaseBundle\DbpRelayBaseBundle::class => ['all' => true], -Dbp\Relay\CoreBundle\DbpRelayCoreBundle => ['all' => true], -]; -``` - -* 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' -``` - -## 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](https://gitlab.tugraz.at/dbp/relay/dbp-relay-base-organization-bundle) | [Packagist](https://packagist.org/packages/dbp/relay-base-organization-bundle) diff --git a/composer.json b/composer.json index aa02e1b..ce0146d 100644 --- a/composer.json +++ b/composer.json @@ -1,11 +1,12 @@ { - "name": "dbp/relay-base-bundle", + "name": "dbp/relay-base-organization-bundle", "type": "symfony-bundle", "license": "AGPL-3.0-or-later", "require": { "php": "^7.3", "ext-json": "*", "api-platform/core": "^2.6.3", + "dbp/relay-base-person-bundle": "^0.1.3", "dbp/relay-core-bundle": "^0.1.11", "guzzlehttp/guzzle": "^7.0", "nelmio/cors-bundle": "^2.1.0", @@ -32,12 +33,12 @@ }, "autoload": { "psr-4": { - "Dbp\\Relay\\BaseBundle\\": "src/" + "Dbp\\Relay\\BaseOrganizationBundle\\": "src/" } }, "autoload-dev": { "psr-4": { - "Dbp\\Relay\\BaseBundle\\Tests\\": "tests/" + "Dbp\\Relay\\BaseOrganizationBundle\\Tests\\": "tests/" } }, "config": { diff --git a/composer.lock b/composer.lock index 485bafb..11993d2 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "412a6debb11df123e57bd8a615074b4b", + "content-hash": "4931b2b2c0918a53773c99da81a7ce0b", "packages": [ { "name": "api-platform/core", @@ -166,13 +166,61 @@ ], "time": "2021-09-29T19:11:04+00:00" }, + { + "name": "dbp/relay-base-person-bundle", + "version": "v0.1.3", + "source": { + "type": "git", + "url": "https://gitlab.tugraz.at/dbp/relay/dbp-relay-base-person-bundle", + "reference": "f7a234362d9d11d2897b7218e1d94cb1ad153f82" + }, + "require": { + "api-platform/core": "^2.6.3", + "dbp/relay-core-bundle": "^0.1.11", + "ext-json": "*", + "guzzlehttp/guzzle": "^7.0", + "nelmio/cors-bundle": "^2.1.0", + "php": "^7.3", + "phpdocumentor/reflection-docblock": "^3.0 || ^4.0 || ^5.0", + "symfony/config": "^5.2", + "symfony/expression-language": "^5.2", + "symfony/framework-bundle": "^5.2", + "symfony/security-bundle": "^5.2", + "symfony/security-core": "^5.2", + "symfony/security-guard": "^5.2", + "symfony/twig-bundle": "^5.2", + "symfony/validator": "^5.2", + "symfony/yaml": "^5.2" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^3.0", + "phpstan/phpstan": "^0.12.33", + "phpstan/phpstan-phpunit": "^0.12.13", + "symfony/browser-kit": "^5.2", + "symfony/http-client": "^5.2", + "symfony/monolog-bundle": "^3.7", + "symfony/phpunit-bridge": "^5.2", + "vimeo/psalm": "^4.4" + }, + "type": "symfony-bundle", + "autoload": { + "psr-4": { + "Dbp\\Relay\\BasePersonBundle\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "AGPL-3.0-or-later" + ], + "time": "2021-10-21T12:26:36+00:00" + }, { "name": "dbp/relay-core-bundle", - "version": "v0.1.16", + "version": "v0.1.18", "source": { "type": "git", "url": "https://gitlab.tugraz.at/dbp/relay/dbp-relay-core-bundle", - "reference": "3c049f19af4bdf0fc3d0c40765deb4da2c169585" + "reference": "86a52bf2dbcdd1258d38208871ac009d924d6396" }, "require": { "api-platform/core": "^2.6.3", @@ -227,7 +275,7 @@ "license": [ "AGPL-3.0-or-later" ], - "time": "2021-09-13T08:02:44+00:00" + "time": "2021-10-20T08:28:56+00:00" }, { "name": "doctrine/annotations", @@ -600,24 +648,25 @@ }, { "name": "guzzlehttp/guzzle", - "version": "7.3.0", + "version": "7.4.0", "source": { "type": "git", "url": "https://github.com/guzzle/guzzle.git", - "reference": "7008573787b430c1c1f650e3722d9bba59967628" + "reference": "868b3571a039f0ebc11ac8f344f4080babe2cb94" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/7008573787b430c1c1f650e3722d9bba59967628", - "reference": "7008573787b430c1c1f650e3722d9bba59967628", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/868b3571a039f0ebc11ac8f344f4080babe2cb94", + "reference": "868b3571a039f0ebc11ac8f344f4080babe2cb94", "shasum": "" }, "require": { "ext-json": "*", - "guzzlehttp/promises": "^1.4", - "guzzlehttp/psr7": "^1.7 || ^2.0", + "guzzlehttp/promises": "^1.5", + "guzzlehttp/psr7": "^1.8.3 || ^2.1", "php": "^7.2.5 || ^8.0", - "psr/http-client": "^1.0" + "psr/http-client": "^1.0", + "symfony/deprecation-contracts": "^2.2" }, "provide": { "psr/http-client-implementation": "1.0" @@ -627,7 +676,7 @@ "ext-curl": "*", "php-http/client-integration-tests": "^3.0", "phpunit/phpunit": "^8.5.5 || ^9.3.5", - "psr/log": "^1.1" + "psr/log": "^1.1 || ^2.0 || ^3.0" }, "suggest": { "ext-curl": "Required for CURL handler support", @@ -637,7 +686,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "7.3-dev" + "dev-master": "7.4-dev" } }, "autoload": { @@ -653,19 +702,43 @@ "MIT" ], "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, { "name": "Michael Dowling", "email": "mtdowling@gmail.com", "homepage": "https://github.com/mtdowling" }, + { + "name": "Jeremy Lindblom", + "email": "jeremeamia@gmail.com", + "homepage": "https://github.com/jeremeamia" + }, + { + "name": "George Mponos", + "email": "gmponos@gmail.com", + "homepage": "https://github.com/gmponos" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, { "name": "Márk Sági-Kazár", "email": "mark.sagikazar@gmail.com", - "homepage": "https://sagikazarmark.hu" + "homepage": "https://github.com/sagikazarmark" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" } ], "description": "Guzzle is a PHP HTTP client library", - "homepage": "http://guzzlephp.org/", "keywords": [ "client", "curl", @@ -679,7 +752,7 @@ ], "support": { "issues": "https://github.com/guzzle/guzzle/issues", - "source": "https://github.com/guzzle/guzzle/tree/7.3.0" + "source": "https://github.com/guzzle/guzzle/tree/7.4.0" }, "funding": [ { @@ -691,28 +764,24 @@ "type": "github" }, { - "url": "https://github.com/alexeyshockov", - "type": "github" - }, - { - "url": "https://github.com/gmponos", - "type": "github" + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/guzzle", + "type": "tidelift" } ], - "time": "2021-03-23T11:33:13+00:00" + "time": "2021-10-18T09:52:00+00:00" }, { "name": "guzzlehttp/promises", - "version": "1.4.1", + "version": "1.5.0", "source": { "type": "git", "url": "https://github.com/guzzle/promises.git", - "reference": "8e7d04f1f6450fef59366c399cfad4b9383aa30d" + "reference": "136a635e2b4a49b9d79e9c8fee267ffb257fdba0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/promises/zipball/8e7d04f1f6450fef59366c399cfad4b9383aa30d", - "reference": "8e7d04f1f6450fef59366c399cfad4b9383aa30d", + "url": "https://api.github.com/repos/guzzle/promises/zipball/136a635e2b4a49b9d79e9c8fee267ffb257fdba0", + "reference": "136a635e2b4a49b9d79e9c8fee267ffb257fdba0", "shasum": "" }, "require": { @@ -724,7 +793,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.4-dev" + "dev-master": "1.5-dev" } }, "autoload": { @@ -740,10 +809,25 @@ "MIT" ], "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, { "name": "Michael Dowling", "email": "mtdowling@gmail.com", "homepage": "https://github.com/mtdowling" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" } ], "description": "Guzzle promises library", @@ -752,22 +836,36 @@ ], "support": { "issues": "https://github.com/guzzle/promises/issues", - "source": "https://github.com/guzzle/promises/tree/1.4.1" + "source": "https://github.com/guzzle/promises/tree/1.5.0" }, - "time": "2021-03-07T09:25:29+00:00" + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/promises", + "type": "tidelift" + } + ], + "time": "2021-10-07T13:05:22+00:00" }, { "name": "guzzlehttp/psr7", - "version": "2.0.0", + "version": "2.1.0", "source": { "type": "git", "url": "https://github.com/guzzle/psr7.git", - "reference": "1dc8d9cba3897165e16d12bb13d813afb1eb3fe7" + "reference": "089edd38f5b8abba6cb01567c2a8aaa47cec4c72" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/1dc8d9cba3897165e16d12bb13d813afb1eb3fe7", - "reference": "1dc8d9cba3897165e16d12bb13d813afb1eb3fe7", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/089edd38f5b8abba6cb01567c2a8aaa47cec4c72", + "reference": "089edd38f5b8abba6cb01567c2a8aaa47cec4c72", "shasum": "" }, "require": { @@ -791,7 +889,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0-dev" + "dev-master": "2.1-dev" } }, "autoload": { @@ -804,13 +902,34 @@ "MIT" ], "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, { "name": "Michael Dowling", "email": "mtdowling@gmail.com", "homepage": "https://github.com/mtdowling" }, + { + "name": "George Mponos", + "email": "gmponos@gmail.com", + "homepage": "https://github.com/gmponos" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://github.com/sagikazarmark" + }, { "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", "homepage": "https://github.com/Tobion" }, { @@ -832,9 +951,23 @@ ], "support": { "issues": "https://github.com/guzzle/psr7/issues", - "source": "https://github.com/guzzle/psr7/tree/2.0.0" + "source": "https://github.com/guzzle/psr7/tree/2.1.0" }, - "time": "2021-06-30T20:03:07+00:00" + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/psr7", + "type": "tidelift" + } + ], + "time": "2021-10-06T17:43:30+00:00" }, { "name": "nelmio/cors-bundle", @@ -952,16 +1085,16 @@ }, { "name": "phpdocumentor/reflection-docblock", - "version": "5.2.2", + "version": "5.3.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "069a785b2141f5bcf49f3e353548dc1cce6df556" + "reference": "622548b623e81ca6d78b721c5e029f4ce664f170" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/069a785b2141f5bcf49f3e353548dc1cce6df556", - "reference": "069a785b2141f5bcf49f3e353548dc1cce6df556", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/622548b623e81ca6d78b721c5e029f4ce664f170", + "reference": "622548b623e81ca6d78b721c5e029f4ce664f170", "shasum": "" }, "require": { @@ -972,7 +1105,8 @@ "webmozart/assert": "^1.9.1" }, "require-dev": { - "mockery/mockery": "~1.3.2" + "mockery/mockery": "~1.3.2", + "psalm/phar": "^4.8" }, "type": "library", "extra": { @@ -1002,22 +1136,22 @@ "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", "support": { "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", - "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/master" + "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.3.0" }, - "time": "2020-09-03T19:13:55+00:00" + "time": "2021-10-19T17:43:47+00:00" }, { "name": "phpdocumentor/type-resolver", - "version": "1.4.0", + "version": "1.5.1", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0" + "reference": "a12f7e301eb7258bb68acd89d4aefa05c2906cae" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0", - "reference": "6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/a12f7e301eb7258bb68acd89d4aefa05c2906cae", + "reference": "a12f7e301eb7258bb68acd89d4aefa05c2906cae", "shasum": "" }, "require": { @@ -1025,7 +1159,8 @@ "phpdocumentor/reflection-common": "^2.0" }, "require-dev": { - "ext-tokenizer": "*" + "ext-tokenizer": "*", + "psalm/phar": "^4.8" }, "type": "library", "extra": { @@ -1051,9 +1186,9 @@ "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", "support": { "issues": "https://github.com/phpDocumentor/TypeResolver/issues", - "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.4.0" + "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.5.1" }, - "time": "2020-09-17T18:55:26+00:00" + "time": "2021-10-02T14:08:47+00:00" }, { "name": "psr/cache", @@ -4734,16 +4869,16 @@ }, { "name": "symfony/twig-bridge", - "version": "v5.3.4", + "version": "v5.3.7", "source": { "type": "git", "url": "https://github.com/symfony/twig-bridge.git", - "reference": "587c45ef49256279502b4a29146b9e87ad23426f" + "reference": "503e12aded4d5cbda4f8d1f3824c6a108119822f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/twig-bridge/zipball/587c45ef49256279502b4a29146b9e87ad23426f", - "reference": "587c45ef49256279502b4a29146b9e87ad23426f", + "url": "https://api.github.com/repos/symfony/twig-bridge/zipball/503e12aded4d5cbda4f8d1f3824c6a108119822f", + "reference": "503e12aded4d5cbda4f8d1f3824c6a108119822f", "shasum": "" }, "require": { @@ -4835,7 +4970,7 @@ "description": "Provides integration for Twig with various Symfony components", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/twig-bridge/tree/v5.3.4" + "source": "https://github.com/symfony/twig-bridge/tree/v5.3.7" }, "funding": [ { @@ -4851,7 +4986,7 @@ "type": "tidelift" } ], - "time": "2021-07-26T16:33:26+00:00" + "time": "2021-08-26T07:28:06+00:00" }, { "name": "symfony/twig-bundle", @@ -5376,16 +5511,16 @@ }, { "name": "twig/twig", - "version": "v3.3.2", + "version": "v3.3.3", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "21578f00e83d4a82ecfa3d50752b609f13de6790" + "reference": "a27fa056df8a6384316288ca8b0fa3a35fdeb569" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/21578f00e83d4a82ecfa3d50752b609f13de6790", - "reference": "21578f00e83d4a82ecfa3d50752b609f13de6790", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/a27fa056df8a6384316288ca8b0fa3a35fdeb569", + "reference": "a27fa056df8a6384316288ca8b0fa3a35fdeb569", "shasum": "" }, "require": { @@ -5395,7 +5530,7 @@ }, "require-dev": { "psr/container": "^1.0", - "symfony/phpunit-bridge": "^4.4.9|^5.0.9" + "symfony/phpunit-bridge": "^4.4.9|^5.0.9|^6.0" }, "type": "library", "extra": { @@ -5436,7 +5571,7 @@ ], "support": { "issues": "https://github.com/twigphp/Twig/issues", - "source": "https://github.com/twigphp/Twig/tree/v3.3.2" + "source": "https://github.com/twigphp/Twig/tree/v3.3.3" }, "funding": [ { @@ -5448,7 +5583,7 @@ "type": "tidelift" } ], - "time": "2021-05-16T12:14:13+00:00" + "time": "2021-09-17T08:44:23+00:00" }, { "name": "webmozart/assert", @@ -5568,16 +5703,16 @@ "packages-dev": [ { "name": "amphp/amp", - "version": "v2.6.0", + "version": "v2.6.1", "source": { "type": "git", "url": "https://github.com/amphp/amp.git", - "reference": "caa95edeb1ca1bf7532e9118ede4a3c3126408cc" + "reference": "c5fc66a78ee38d7ac9195a37bacaf940eb3f65ae" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/amphp/amp/zipball/caa95edeb1ca1bf7532e9118ede4a3c3126408cc", - "reference": "caa95edeb1ca1bf7532e9118ede4a3c3126408cc", + "url": "https://api.github.com/repos/amphp/amp/zipball/c5fc66a78ee38d7ac9195a37bacaf940eb3f65ae", + "reference": "c5fc66a78ee38d7ac9195a37bacaf940eb3f65ae", "shasum": "" }, "require": { @@ -5645,7 +5780,7 @@ "support": { "irc": "irc://irc.freenode.org/amphp", "issues": "https://github.com/amphp/amp/issues", - "source": "https://github.com/amphp/amp/tree/v2.6.0" + "source": "https://github.com/amphp/amp/tree/v2.6.1" }, "funding": [ { @@ -5653,7 +5788,7 @@ "type": "github" } ], - "time": "2021-07-16T20:06:06+00:00" + "time": "2021-09-23T18:43:08+00:00" }, { "name": "amphp/byte-stream", @@ -5734,16 +5869,16 @@ }, { "name": "composer/package-versions-deprecated", - "version": "1.11.99.3", + "version": "1.11.99.4", "source": { "type": "git", "url": "https://github.com/composer/package-versions-deprecated.git", - "reference": "fff576ac850c045158a250e7e27666e146e78d18" + "reference": "b174585d1fe49ceed21928a945138948cb394600" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/package-versions-deprecated/zipball/fff576ac850c045158a250e7e27666e146e78d18", - "reference": "fff576ac850c045158a250e7e27666e146e78d18", + "url": "https://api.github.com/repos/composer/package-versions-deprecated/zipball/b174585d1fe49ceed21928a945138948cb394600", + "reference": "b174585d1fe49ceed21928a945138948cb394600", "shasum": "" }, "require": { @@ -5787,7 +5922,7 @@ "description": "Composer plugin that provides efficient querying for installed package versions (no runtime IO)", "support": { "issues": "https://github.com/composer/package-versions-deprecated/issues", - "source": "https://github.com/composer/package-versions-deprecated/tree/1.11.99.3" + "source": "https://github.com/composer/package-versions-deprecated/tree/1.11.99.4" }, "funding": [ { @@ -5803,7 +5938,7 @@ "type": "tidelift" } ], - "time": "2021-08-17T13:49:14+00:00" + "time": "2021-09-13T08:41:34+00:00" }, { "name": "composer/semver", @@ -6180,24 +6315,24 @@ }, { "name": "monolog/monolog", - "version": "2.3.2", + "version": "2.3.5", "source": { "type": "git", "url": "https://github.com/Seldaek/monolog.git", - "reference": "71312564759a7db5b789296369c1a264efc43aad" + "reference": "fd4380d6fc37626e2f799f29d91195040137eba9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Seldaek/monolog/zipball/71312564759a7db5b789296369c1a264efc43aad", - "reference": "71312564759a7db5b789296369c1a264efc43aad", + "url": "https://api.github.com/repos/Seldaek/monolog/zipball/fd4380d6fc37626e2f799f29d91195040137eba9", + "reference": "fd4380d6fc37626e2f799f29d91195040137eba9", "shasum": "" }, "require": { "php": ">=7.2", - "psr/log": "^1.0.1" + "psr/log": "^1.0.1 || ^2.0 || ^3.0" }, "provide": { - "psr/log-implementation": "1.0.0" + "psr/log-implementation": "1.0.0 || 2.0.0 || 3.0.0" }, "require-dev": { "aws/aws-sdk-php": "^2.4.9 || ^3.0", @@ -6205,14 +6340,14 @@ "elasticsearch/elasticsearch": "^7", "graylog2/gelf-php": "^1.4.2", "mongodb/mongodb": "^1.8", - "php-amqplib/php-amqplib": "~2.4", + "php-amqplib/php-amqplib": "~2.4 || ^3", "php-console/php-console": "^3.1.3", "phpspec/prophecy": "^1.6.1", "phpstan/phpstan": "^0.12.91", "phpunit/phpunit": "^8.5", "predis/predis": "^1.1", "rollbar/rollbar": "^1.3", - "ruflin/elastica": ">=0.90 <7.0.1", + "ruflin/elastica": ">=0.90@dev", "swiftmailer/swiftmailer": "^5.3|^6.0" }, "suggest": { @@ -6220,8 +6355,11 @@ "doctrine/couchdb": "Allow sending log messages to a CouchDB server", "elasticsearch/elasticsearch": "Allow sending log messages to an Elasticsearch server via official client", "ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)", + "ext-curl": "Required to send log messages using the IFTTTHandler, the LogglyHandler, the SendGridHandler, the SlackWebhookHandler or the TelegramBotHandler", "ext-mbstring": "Allow to work properly with unicode symbols", "ext-mongodb": "Allow sending log messages to a MongoDB server (via driver)", + "ext-openssl": "Required to send log messages using SSL", + "ext-sockets": "Allow sending log messages to a Syslog server (via UDP driver)", "graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server", "mongodb/mongodb": "Allow sending log messages to a MongoDB server (via library)", "php-amqplib/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib", @@ -6260,7 +6398,7 @@ ], "support": { "issues": "https://github.com/Seldaek/monolog/issues", - "source": "https://github.com/Seldaek/monolog/tree/2.3.2" + "source": "https://github.com/Seldaek/monolog/tree/2.3.5" }, "funding": [ { @@ -6272,7 +6410,7 @@ "type": "tidelift" } ], - "time": "2021-07-23T07:42:52+00:00" + "time": "2021-10-01T21:08:31+00:00" }, { "name": "netresearch/jsonmapper", @@ -6327,16 +6465,16 @@ }, { "name": "nikic/php-parser", - "version": "v4.12.0", + "version": "v4.13.0", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "6608f01670c3cc5079e18c1dab1104e002579143" + "reference": "50953a2691a922aa1769461637869a0a2faa3f53" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/6608f01670c3cc5079e18c1dab1104e002579143", - "reference": "6608f01670c3cc5079e18c1dab1104e002579143", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/50953a2691a922aa1769461637869a0a2faa3f53", + "reference": "50953a2691a922aa1769461637869a0a2faa3f53", "shasum": "" }, "require": { @@ -6377,9 +6515,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v4.12.0" + "source": "https://github.com/nikic/PHP-Parser/tree/v4.13.0" }, - "time": "2021-07-21T10:44:31+00:00" + "time": "2021-09-20T12:20:58+00:00" }, { "name": "openlss/lib-array2xml", @@ -6843,16 +6981,16 @@ }, { "name": "symfony/dom-crawler", - "version": "v5.3.4", + "version": "v5.3.7", "source": { "type": "git", "url": "https://github.com/symfony/dom-crawler.git", - "reference": "2dd8890bd01be59a5221999c05ccf0fcafcb354f" + "reference": "c7eef3a60ccfdd8eafe07f81652e769ac9c7146c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/2dd8890bd01be59a5221999c05ccf0fcafcb354f", - "reference": "2dd8890bd01be59a5221999c05ccf0fcafcb354f", + "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/c7eef3a60ccfdd8eafe07f81652e769ac9c7146c", + "reference": "c7eef3a60ccfdd8eafe07f81652e769ac9c7146c", "shasum": "" }, "require": { @@ -6898,7 +7036,7 @@ "description": "Eases DOM navigation for HTML and XML documents", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/dom-crawler/tree/v5.3.4" + "source": "https://github.com/symfony/dom-crawler/tree/v5.3.7" }, "funding": [ { @@ -6914,7 +7052,7 @@ "type": "tidelift" } ], - "time": "2021-07-23T15:55:36+00:00" + "time": "2021-08-29T19:32:13+00:00" }, { "name": "symfony/http-client", @@ -7005,16 +7143,16 @@ }, { "name": "symfony/monolog-bridge", - "version": "v5.3.4", + "version": "v5.3.7", "source": { "type": "git", "url": "https://github.com/symfony/monolog-bridge.git", - "reference": "a0d881165b902a04f41e873426aa52a068064ac4" + "reference": "4ace41087254f099b6743333155071438bfb12c3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/monolog-bridge/zipball/a0d881165b902a04f41e873426aa52a068064ac4", - "reference": "a0d881165b902a04f41e873426aa52a068064ac4", + "url": "https://api.github.com/repos/symfony/monolog-bridge/zipball/4ace41087254f099b6743333155071438bfb12c3", + "reference": "4ace41087254f099b6743333155071438bfb12c3", "shasum": "" }, "require": { @@ -7069,7 +7207,7 @@ "description": "Provides integration for Monolog with various Symfony components", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/monolog-bridge/tree/v5.3.4" + "source": "https://github.com/symfony/monolog-bridge/tree/v5.3.7" }, "funding": [ { @@ -7085,7 +7223,7 @@ "type": "tidelift" } ], - "time": "2021-07-23T15:55:36+00:00" + "time": "2021-08-13T15:54:02+00:00" }, { "name": "symfony/monolog-bundle", diff --git a/phpstan.neon b/phpstan.neon index ff5590a..850221c 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -11,5 +11,4 @@ parameters: - vendor/bin/.phpunit/phpunit-9-0/vendor/autoload.php excludes_analyse: - tests/bootstrap.php - - src/Swagger/DocumentationNormalizer.php ignoreErrors: diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 0d0c4df..3496479 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -15,7 +15,7 @@ <server name="SYMFONY_PHPUNIT_REMOVE" value=""/> <server name="SYMFONY_PHPUNIT_VERSION" value="9"/> <server name="SYMFONY_DEPRECATIONS_HELPER" value="weak"/> - <server name="KERNEL_CLASS" value="Dbp\Relay\BaseBundle\Tests\Kernel"/> + <server name="KERNEL_CLASS" value="Dbp\Relay\BaseOrganizationBundle\Tests\Kernel"/> </php> <testsuites> <testsuite name="Project Test Suite"> diff --git a/requests/.gitignore b/requests/.gitignore deleted file mode 100644 index 9f6c78e..0000000 --- a/requests/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.private.env.json diff --git a/requests/README.md b/requests/README.md deleted file mode 100644 index 62937ec..0000000 --- a/requests/README.md +++ /dev/null @@ -1,6 +0,0 @@ -# HTTP Requests - -This request files work with PhpStorm. You can use them to test api requests. - -You need to create a `http-client.private.env.json` (use `http-client.private.env.exam.json`) -for tokens like the current bearer token. \ No newline at end of file diff --git a/requests/get-requests.http b/requests/get-requests.http deleted file mode 100644 index dd20081..0000000 --- a/requests/get-requests.http +++ /dev/null @@ -1,13 +0,0 @@ -# Get information about one organization -GET http://127.0.0.1:8000/organizations/1190-F2050?lang=de -accept: application/ld+json -Authorization: Bearer {{bearer_token}} - -### - -# Search for users with name "Hands" -GET {{entry_point_url}}/people?search=Hans&page=1 -accept: application/ld+json -Authorization: Bearer {{bearer_token}} - -### diff --git a/requests/http-client.env.json b/requests/http-client.env.json deleted file mode 100644 index 0c51410..0000000 --- a/requests/http-client.env.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "local-dev": { - "entry_point_url": "http://127.0.0.1:8000", - // private stuff goes to http-client.private.env.json - "bearer_token": "" - }, - "dev": { - "entry_point_url": "https://mw-dev.tugraz.at", - // private stuff goes to http-client.private.env.json - "bearer_token": "" - } -} \ No newline at end of file diff --git a/requests/http-client.private.env.exam.json b/requests/http-client.private.env.exam.json deleted file mode 100644 index b4601be..0000000 --- a/requests/http-client.private.env.exam.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "local-dev": { - "bearer_token": "eyJhbGciOiJS_and_the_rest_of_it" - }, - "dev": { - "bearer_token": "eyJhbGciOiJS_and_the_rest_of_it" - } -} \ No newline at end of file diff --git a/src/API/OrganizationProviderInterface.php b/src/API/OrganizationProviderInterface.php index 61652dc..efa2d32 100644 --- a/src/API/OrganizationProviderInterface.php +++ b/src/API/OrganizationProviderInterface.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace Dbp\Relay\BaseBundle\API; +namespace Dbp\Relay\BaseOrganizationBundle\API; -use Dbp\Relay\BaseBundle\Entity\Organization; -use Dbp\Relay\BaseBundle\Entity\Person; +use Dbp\Relay\BaseOrganizationBundle\Entity\Organization; +use Dbp\Relay\BasePersonBundle\Entity\Person; interface OrganizationProviderInterface { diff --git a/src/API/PersonProviderInterface.php b/src/API/PersonProviderInterface.php deleted file mode 100644 index f1da3af..0000000 --- a/src/API/PersonProviderInterface.php +++ /dev/null @@ -1,38 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Dbp\Relay\BaseBundle\API; - -use Dbp\Relay\BaseBundle\Entity\Person; - -interface 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; - - /** - * @return Person[] - */ - public function getPersonsByNameAndBirthDate(string $givenName, string $familyName, string $birthDate): array; - - 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; - - /** - * 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; -} diff --git a/src/Controller/GetOrganizationsByPerson.php b/src/Controller/GetOrganizationsByPerson.php index 20304d3..82878e4 100644 --- a/src/Controller/GetOrganizationsByPerson.php +++ b/src/Controller/GetOrganizationsByPerson.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace Dbp\Relay\BaseBundle\Controller; +namespace Dbp\Relay\BaseOrganizationBundle\Controller; use ApiPlatform\Core\DataProvider\PaginatorInterface; -use Dbp\Relay\BaseBundle\API\OrganizationProviderInterface; -use Dbp\Relay\BaseBundle\API\PersonProviderInterface; +use Dbp\Relay\BaseOrganizationBundle\API\OrganizationProviderInterface; +use Dbp\Relay\BasePersonBundle\API\PersonProviderInterface; use Dbp\Relay\CoreBundle\Exception\ApiError; use Dbp\Relay\CoreBundle\Helpers\ArrayFullPaginator; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; diff --git a/src/DataProvider/OrganizationCollectionDataProvider.php b/src/DataProvider/OrganizationCollectionDataProvider.php index 94946b1..d04a5a9 100644 --- a/src/DataProvider/OrganizationCollectionDataProvider.php +++ b/src/DataProvider/OrganizationCollectionDataProvider.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace Dbp\Relay\BaseBundle\DataProvider; +namespace Dbp\Relay\BaseOrganizationBundle\DataProvider; use ApiPlatform\Core\DataProvider\ContextAwareCollectionDataProviderInterface; use ApiPlatform\Core\DataProvider\RestrictedDataProviderInterface; -use Dbp\Relay\BaseBundle\API\OrganizationProviderInterface; -use Dbp\Relay\BaseBundle\Entity\Organization; +use Dbp\Relay\BaseOrganizationBundle\API\OrganizationProviderInterface; +use Dbp\Relay\BaseOrganizationBundle\Entity\Organization; use Dbp\Relay\CoreBundle\Helpers\ArrayFullPaginator; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; diff --git a/src/DataProvider/OrganizationDataProvider.php b/src/DataProvider/OrganizationDataProvider.php index 05f4bb1..5ef0f12 100644 --- a/src/DataProvider/OrganizationDataProvider.php +++ b/src/DataProvider/OrganizationDataProvider.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace Dbp\Relay\BaseBundle\DataProvider; +namespace Dbp\Relay\BaseOrganizationBundle\DataProvider; use ApiPlatform\Core\DataProvider\ItemDataProviderInterface; use ApiPlatform\Core\DataProvider\RestrictedDataProviderInterface; -use Dbp\Relay\BaseBundle\API\OrganizationProviderInterface; -use Dbp\Relay\BaseBundle\Entity\Organization; +use Dbp\Relay\BaseOrganizationBundle\API\OrganizationProviderInterface; +use Dbp\Relay\BaseOrganizationBundle\Entity\Organization; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; final class OrganizationDataProvider extends AbstractController implements ItemDataProviderInterface, RestrictedDataProviderInterface diff --git a/src/DataProvider/PersonCollectionDataProvider.php b/src/DataProvider/PersonCollectionDataProvider.php deleted file mode 100644 index af6d671..0000000 --- a/src/DataProvider/PersonCollectionDataProvider.php +++ /dev/null @@ -1,54 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Dbp\Relay\BaseBundle\DataProvider; - -use ApiPlatform\Core\DataProvider\CollectionDataProviderInterface; -use ApiPlatform\Core\DataProvider\RestrictedDataProviderInterface; -use Dbp\Relay\BaseBundle\API\PersonProviderInterface; -use Dbp\Relay\BaseBundle\Entity\Person; -use Dbp\Relay\CoreBundle\Helpers\ArrayFullPaginator; -use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; - -final class PersonCollectionDataProvider extends AbstractController implements CollectionDataProviderInterface, RestrictedDataProviderInterface -{ - public const ITEMS_PER_PAGE = 250; - - private $api; - - public function __construct(PersonProviderInterface $api) - { - $this->api = $api; - } - - public function supports(string $resourceClass, string $operationName = null, array $context = []): bool - { - return Person::class === $resourceClass; - } - - public function getCollection(string $resourceClass, string $operationName = null, array $context = []): ArrayFullPaginator - { - $this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY'); - - $perPage = self::ITEMS_PER_PAGE; - $page = 1; - $api = $this->api; - $filters = $context['filters'] ?? []; - - if (isset($context['filters']['page'])) { - $page = (int) $context['filters']['page']; - } - - if (isset($context['filters']['perPage'])) { - $perPage = (int) $context['filters']['perPage']; - } - - $persons = $api->getPersons($filters); - - // TODO: do pagination via API - $pagination = new ArrayFullPaginator($persons, $page, $perPage); - - return $pagination; - } -} diff --git a/src/DataProvider/PersonItemDataProvider.php b/src/DataProvider/PersonItemDataProvider.php deleted file mode 100644 index dac2f64..0000000 --- a/src/DataProvider/PersonItemDataProvider.php +++ /dev/null @@ -1,37 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Dbp\Relay\BaseBundle\DataProvider; - -use ApiPlatform\Core\DataProvider\ItemDataProviderInterface; -use ApiPlatform\Core\DataProvider\RestrictedDataProviderInterface; -use Dbp\Relay\BaseBundle\API\PersonProviderInterface; -use Dbp\Relay\BaseBundle\Entity\Person; -use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; - -final class PersonItemDataProvider extends AbstractController implements ItemDataProviderInterface, RestrictedDataProviderInterface -{ - private $api; - - public function __construct(PersonProviderInterface $api) - { - $this->api = $api; - } - - public function supports(string $resourceClass, string $operationName = null, array $context = []): bool - { - return Person::class === $resourceClass; - } - - public function getItem(string $resourceClass, $id, string $operationName = null, array $context = []): ?Person - { - $this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY'); - - $person = null; - $api = $this->api; - $person = $api->getPerson($id); - - return $person; - } -} diff --git a/src/DbpRelayBaseBundle.php b/src/DbpRelayBaseOrganizationBundle.php similarity index 69% rename from src/DbpRelayBaseBundle.php rename to src/DbpRelayBaseOrganizationBundle.php index 13da1f8..e352341 100644 --- a/src/DbpRelayBaseBundle.php +++ b/src/DbpRelayBaseOrganizationBundle.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace Dbp\Relay\BaseBundle; +namespace Dbp\Relay\BaseOrganizationBundle; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Bundle\Bundle; -class DbpRelayBaseBundle extends Bundle +class DbpRelayBaseOrganizationBundle extends Bundle { public function build(ContainerBuilder $container) { diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index fc9b320..1e09fe1 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Dbp\Relay\BaseBundle\DependencyInjection; +namespace Dbp\Relay\BaseOrganizationBundle\DependencyInjection; use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\ConfigurationInterface; @@ -11,7 +11,7 @@ class Configuration implements ConfigurationInterface { public function getConfigTreeBuilder() { - $treeBuilder = new TreeBuilder('dbp_relay_base'); + $treeBuilder = new TreeBuilder('dbp_relay_base_organization'); return $treeBuilder; } diff --git a/src/DependencyInjection/DbpRelayBaseExtension.php b/src/DependencyInjection/DbpRelayBaseOrganizationExtension.php similarity index 89% rename from src/DependencyInjection/DbpRelayBaseExtension.php rename to src/DependencyInjection/DbpRelayBaseOrganizationExtension.php index c0025d9..1816302 100644 --- a/src/DependencyInjection/DbpRelayBaseExtension.php +++ b/src/DependencyInjection/DbpRelayBaseOrganizationExtension.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace Dbp\Relay\BaseBundle\DependencyInjection; +namespace Dbp\Relay\BaseOrganizationBundle\DependencyInjection; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; use Symfony\Component\HttpKernel\DependencyInjection\ConfigurableExtension; -class DbpRelayBaseExtension extends ConfigurableExtension +class DbpRelayBaseOrganizationExtension extends ConfigurableExtension { public function loadInternal(array $mergedConfig, ContainerBuilder $container) { diff --git a/src/Entity/Organization.php b/src/Entity/Organization.php index 76d5aa9..063ab07 100644 --- a/src/Entity/Organization.php +++ b/src/Entity/Organization.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace Dbp\Relay\BaseBundle\Entity; +namespace Dbp\Relay\BaseOrganizationBundle\Entity; use ApiPlatform\Core\Annotation\ApiResource; -use Dbp\Relay\BaseBundle\Controller\GetOrganizationsByPerson; +use Dbp\Relay\BaseOrganizationBundle\Controller\GetOrganizationsByPerson; use Symfony\Component\Serializer\Annotation\Groups; /** @@ -14,7 +14,7 @@ use Symfony\Component\Serializer\Annotation\Groups; * "get" = { * "path" = "/organizations", * "openapi_context" = { - * "tags" = {"Base"}, + * "tags" = {"BaseOrganization"}, * "parameters" = { * {"name" = "lang", "in" = "query", "description" = "Language of result", "type" = "string", "enum" = {"de", "en"}, "example" = "de"} * } @@ -26,7 +26,7 @@ use Symfony\Component\Serializer\Annotation\Groups; * "controller" = GetOrganizationsByPerson::class, * "read" = false, * "openapi_context" = { - * "tags" = {"Base"}, + * "tags" = {"BaseOrganization"}, * "summary" = "Get the organizations related to a person.", * "parameters" = { * {"name" = "identifier", "in" = "path", "description" = "Id of person", "required" = true, "type" = "string", "example" = "vlts01"}, @@ -40,7 +40,7 @@ use Symfony\Component\Serializer\Annotation\Groups; * "get" = { * "path" = "/organizations/{identifier}", * "openapi_context" = { - * "tags" = {"Base"}, + * "tags" = {"BaseOrganization"}, * "parameters" = { * {"name" = "identifier", "in" = "path", "description" = "orgUnitID of organization", "required" = true, "type" = "string", "example" = "1190-F2050"}, * {"name" = "lang", "in" = "query", "description" = "Language of result", "type" = "string", "enum" = {"de", "en"}, "example" = "de"} diff --git a/src/Entity/OrganizationTrait.php b/src/Entity/OrganizationTrait.php index b11bcf1..e03480a 100644 --- a/src/Entity/OrganizationTrait.php +++ b/src/Entity/OrganizationTrait.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Dbp\Relay\BaseBundle\Entity; +namespace Dbp\Relay\BaseOrganizationBundle\Entity; use ApiPlatform\Core\Annotation\ApiProperty; use Symfony\Component\Serializer\Annotation\Groups; diff --git a/src/Entity/Person.php b/src/Entity/Person.php deleted file mode 100644 index c205e83..0000000 --- a/src/Entity/Person.php +++ /dev/null @@ -1,42 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Dbp\Relay\BaseBundle\Entity; - -use ApiPlatform\Core\Annotation\ApiResource; - -/** - * @ApiResource( - * collectionOperations={ - * "get" = { - * "path" = "/people", - * "openapi_context" = { - * "tags" = {"Base"}, - * "parameters" = { - * {"name" = "search", "in" = "query", "description" = "Search for a person name", "type" = "string", "example" = "woody007"} - * } - * } - * }, - * }, - * itemOperations={ - * "get" = { - * "path" = "/people/{identifier}", - * "openapi_context" = { - * "tags" = {"Base"}, - * } - * - * }, - * }, - * iri="http://schema.org/Person", - * description="A person of the LDAP system", - * normalizationContext={ - * "groups" = {"BasePerson:output"}, - * "jsonld_embed_context" = true, - * } - * ) - */ -class Person -{ - use PersonTrait; -} diff --git a/src/Entity/PersonTrait.php b/src/Entity/PersonTrait.php deleted file mode 100644 index c323c15..0000000 --- a/src/Entity/PersonTrait.php +++ /dev/null @@ -1,147 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Dbp\Relay\BaseBundle\Entity; - -use ApiPlatform\Core\Annotation\ApiProperty; -use Symfony\Component\Serializer\Annotation\Groups; - -trait PersonTrait -{ - /** - * @ApiProperty(identifier=true) - * @Groups({"BasePerson:output"}) - * - * @var string - */ - private $identifier; - - /** - * @ApiProperty(iri="http://schema.org/givenName") - * @Groups({"BasePerson:output"}) - * - * @var string - */ - private $givenName; - - /** - * @var string - * @ApiProperty(iri="http://schema.org/familyName") - * @Groups({"BasePerson:output"}) - * - * @var string - */ - private $familyName; - - /** - * @ApiProperty(iri="http://schema.org/email") - * @Groups({"BasePerson:current-user", "BasePerson:extended-access"}) - * - * @var string - */ - private $email; - - /** - * @var array - * @Groups({"BasePerson:current-user"}) - */ - private $roles; - - /** - * @var string - * @ApiProperty(iri="http://schema.org/birthDate") - * @Groups({"BasePerson:current-user"}) - */ - private $birthDate; - - /** - * @var array - */ - private $extraData; - - public function __construct() - { - $this->extraData = []; - $this->roles = []; - } - - public function setIdentifier(string $identifier) - { - $this->identifier = $identifier; - } - - public function getIdentifier(): ?string - { - return $this->identifier; - } - - public function getGivenName(): ?string - { - return $this->givenName; - } - - public function setGivenName(?string $givenName) - { - $this->givenName = $givenName; - } - - public function getFamilyName(): ?string - { - return $this->familyName; - } - - public function setFamilyName(?string $familyName) - { - $this->familyName = $familyName; - } - - public function getEmail(): ?string - { - return $this->email; - } - - public function setEmail(?string $email) - { - $this->email = $email; - } - - /** - * Allows attaching extra information to a Person object with - * some random key. You can get the value back via getExtraData(). - * - * @param ?mixed $value - */ - public function setExtraData(string $key, $value): void - { - $this->extraData[$key] = $value; - } - - /** - * @return ?mixed - */ - public function getExtraData(string $key) - { - return $this->extraData[$key] ?? null; - } - - public function getRoles(): array - { - return $this->roles; - } - - public function setRoles(array $roles) - { - $this->roles = $roles; - } - - public function getBirthDate(): ?string - { - return $this->birthDate; - } - - public function setBirthDate(string $birthDate) - { - $this->birthDate = $birthDate; - } -} diff --git a/src/Resources/config/services.yaml b/src/Resources/config/services.yaml index 294ddb3..c0b8fdb 100644 --- a/src/Resources/config/services.yaml +++ b/src/Resources/config/services.yaml @@ -1,33 +1,17 @@ services: - Dbp\Relay\BaseBundle\Controller\: + Dbp\Relay\BaseOrganizationBundle\Controller\: resource: '../../Controller' autowire: true autoconfigure: true - Dbp\Relay\BaseBundle\API\OrganizationProviderInterface: - '@Dbp\Relay\BaseBundle\Service\DummyOrganizationProvider' - - Dbp\Relay\BaseBundle\Service\DummyOrganizationProvider: - autowire: true - autoconfigure: true - - Dbp\Relay\BaseBundle\Service\DummyPersonProvider: - autowire: true - autoconfigure: true - - Dbp\Relay\BaseBundle\API\PersonProviderInterface: - '@Dbp\Relay\BaseBundle\Service\DummyPersonProvider' - - Dbp\Relay\BaseBundle\DataProvider\: + Dbp\Relay\BaseOrganizationBundle\DataProvider\: resource: '../../DataProvider' autowire: true autoconfigure: true - Dbp\Relay\BaseBundle\Serializer\PersonAttributeNormalizer: - autowire: true - autoconfigure: true + Dbp\Relay\BaseOrganizationBundle\API\OrganizationProviderInterface: + '@Dbp\Relay\BaseOrganizationBundle\Service\DummyOrganizationProvider' - # This alias exist so we can replace the service during tests - test.PersonProviderInterface: - alias: 'Dbp\Relay\BaseBundle\API\PersonProviderInterface' - public: true + Dbp\Relay\BaseOrganizationBundle\Service\DummyOrganizationProvider: + autowire: true + autoconfigure: true \ No newline at end of file diff --git a/src/Serializer/PersonAttributeNormalizer.php b/src/Serializer/PersonAttributeNormalizer.php deleted file mode 100644 index 66c088e..0000000 --- a/src/Serializer/PersonAttributeNormalizer.php +++ /dev/null @@ -1,60 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Dbp\Relay\BaseBundle\Serializer; - -use Dbp\Relay\BaseBundle\Entity\Person; -use Symfony\Component\Security\Core\Security; -use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface; -use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface; -use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait; - -class PersonAttributeNormalizer implements ContextAwareNormalizerInterface, NormalizerAwareInterface -{ - use NormalizerAwareTrait; - - private const ALREADY_CALLED = 'LDAP_PERSON_ATTRIBUTE_NORMALIZER_CURRENT_USER_ALREADY_CALLED'; - - /** - * @var Security - */ - private $security; - - public function __construct(Security $security) - { - $this->security = $security; - } - - public function normalize($object, $format = null, array $context = []) - { - // set the group "Person:current-user" for the current user - if ($this->isCurrentUser($object)) { - $context['groups'][] = 'BasePerson:current-user'; - } - - $context[self::ALREADY_CALLED] = true; - - return $this->normalizer->normalize($object, $format, $context); - } - - public function supportsNormalization($data, $format = null, array $context = []) - { - // Make sure we're not called twice - if (isset($context[self::ALREADY_CALLED])) { - return false; - } - - return $data instanceof Person; - } - - /** - * @param Person $object - */ - private function isCurrentUser($object): bool - { - $user = $this->security->getUser(); - - return $user ? $user->getUsername() === $object->getIdentifier() : false; - } -} diff --git a/src/Service/DummyOrganizationProvider.php b/src/Service/DummyOrganizationProvider.php index dc6766d..2376a47 100644 --- a/src/Service/DummyOrganizationProvider.php +++ b/src/Service/DummyOrganizationProvider.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace Dbp\Relay\BaseBundle\Service; +namespace Dbp\Relay\BaseOrganizationBundle\Service; -use Dbp\Relay\BaseBundle\API\OrganizationProviderInterface; -use Dbp\Relay\BaseBundle\Entity\Organization; -use Dbp\Relay\BaseBundle\Entity\Person; +use Dbp\Relay\BaseOrganizationBundle\API\OrganizationProviderInterface; +use Dbp\Relay\BaseOrganizationBundle\Entity\Organization; +use Dbp\Relay\BasePersonBundle\Entity\Person; class DummyOrganizationProvider implements OrganizationProviderInterface { diff --git a/src/Service/DummyPersonProvider.php b/src/Service/DummyPersonProvider.php deleted file mode 100644 index c3641ff..0000000 --- a/src/Service/DummyPersonProvider.php +++ /dev/null @@ -1,83 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Dbp\Relay\BaseBundle\Service; - -use Dbp\Relay\BaseBundle\API\PersonProviderInterface; -use Dbp\Relay\BaseBundle\Entity\Person; - -class DummyPersonProvider implements PersonProviderInterface -{ - /** - * @var string|null - */ - private $currentIdentifier; - - public function __construct() - { - $this->currentIdentifier = null; - } - - public function getPersons(array $filters): array - { - $person = $this->getCurrentPerson(); - if ($person !== null) { - return [$person]; - } - - return []; - } - - public function getPersonsByNameAndBirthDate(string $givenName, string $familyName, string $birthDate): array - { - return []; - } - - public function getPerson(string $id): 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 - { - if ($this->currentIdentifier === null) { - return null; - } - - return $this->getPerson($this->currentIdentifier); - } - - public function getPersonForExternalService(string $service, string $serviceID): Person - { - return new Person(); - } - - public function setCurrentIdentifier(string $identifier): void - { - $this->currentIdentifier = $identifier; - } - - public function getRolesForCurrentPerson(): array - { - if ($this->currentIdentifier === null) { - return []; - } - - return $this->getCurrentPerson()->getRoles(); - } - - public function setRolesForCurrentPerson(array $roles): void - { - if ($this->currentIdentifier === null) { - return; - } - $this->getCurrentPerson()->setRoles($roles); - } -} diff --git a/src/TestUtils/DummyPersonProvider.php b/src/TestUtils/DummyPersonProvider.php deleted file mode 100644 index 81c0d5c..0000000 --- a/src/TestUtils/DummyPersonProvider.php +++ /dev/null @@ -1,65 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Dbp\Relay\BaseBundle\TestUtils; - -use ApiPlatform\Core\Exception\ItemNotFoundException; -use Dbp\Relay\BaseBundle\API\PersonProviderInterface; -use Dbp\Relay\BaseBundle\Entity\Person; -use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; - -class DummyPersonProvider implements PersonProviderInterface -{ - /* @var Person */ - private $person; - - public function __construct($person) - { - $this->person = $person; - } - - public function getPersons(array $filters): array - { - return [$this->person]; - } - - public function getPerson(string $id): Person - { - if ($id !== $this->person->getIdentifier()) { - throw new NotFoundHttpException(); - } - - return $this->person; - } - - public function getCurrentPerson(): Person - { - return $this->person; - } - - public function getPersonForExternalService(string $service, string $serviceID): Person - { - throw new ItemNotFoundException(); - } - - public function getPersonsByNameAndBirthDate(string $givenName, string $familyName, string $birthDate): array - { - return []; - } - - public function setCurrentIdentifier(string $identifier): void - { - $this->person->setIdentifier($identifier); - } - - public function getRolesForCurrentPerson(): array - { - return $this->person->getRoles(); - } - - public function setRolesForCurrentPerson(array $roles): void - { - $this->person->setRoles($roles); - } -} diff --git a/tests/ExtTest.php b/tests/ExtTest.php index 8ceeed2..e11f5d6 100644 --- a/tests/ExtTest.php +++ b/tests/ExtTest.php @@ -2,102 +2,18 @@ declare(strict_types=1); -namespace Dbp\Relay\BaseBundle\Tests; +namespace Dbp\Relay\BaseOrganizationBundle\Tests; use ApiPlatform\Core\Bridge\Symfony\Bundle\Test\ApiTestCase; -use ApiPlatform\Core\Bridge\Symfony\Bundle\Test\Client; -use Dbp\Relay\BaseBundle\Entity\Person; -use Dbp\Relay\BaseBundle\TestUtils\DummyPersonProvider; -use Dbp\Relay\CoreBundle\TestUtils\UserAuthTrait; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\Security\Core\User\UserInterface; class ExtTest extends ApiTestCase { - use UserAuthTrait; - - private function withPerson(Client $client, UserInterface $user): Person - { - $person = new Person(); - $person->setIdentifier($user->getUserIdentifier()); - $person->setRoles($user->getRoles()); - $personProvider = new DummyPersonProvider($person); - $container = $client->getContainer(); - $container->set('test.PersonProviderInterface', $personProvider); - - return $person; - } - - public function testGetPersonNoAuth() - { - $client = $this->withUser('foobar', ['foo']); - $response = $client->request('GET', '/people/foobar'); - $this->assertEquals(Response::HTTP_UNAUTHORIZED, $response->getStatusCode()); - } - - public function testGetPersonWrongAuth() - { - $client = $this->withUser('foobar', [], '42'); - $response = $client->request('GET', '/people/foobar', ['headers' => [ - 'Authorization' => 'Bearer NOT42', - ]]); - $this->assertEquals(Response::HTTP_FORBIDDEN, $response->getStatusCode()); - } - - public function testGetPerson() - { - $client = $this->withUser('foobar', [], '42'); - $user = $this->getUser($client); - $person = $this->withPerson($client, $user); - $person->setEmail('foo@bar.com'); - $response = $client->request('GET', '/people/foobar', ['headers' => [ - 'Authorization' => 'Bearer 42', - ]]); - $this->assertJson($response->getContent(false)); - $data = json_decode($response->getContent(false), true, 512, JSON_THROW_ON_ERROR); - $this->assertEquals('/people/foobar', $data['@id']); - $this->assertEquals('foobar', $data['identifier']); - $this->assertEquals('foo@bar.com', $data['email']); - } - - public function testResponseHeaders() - { - $client = $this->withUser('foobar', [], '42'); - $response = $client->request('GET', '/people/foobar', ['headers' => [ - 'Authorization' => 'Bearer 42', - ]]); - $header = $response->getHeaders(); - - // We extend the defaults with CORS related headers - $this->assertArrayHasKey('vary', $header); - $this->assertContains('Accept', $header['vary']); - $this->assertContains('Origin', $header['vary']); - $this->assertContains('Access-Control-Request-Headers', $header['vary']); - $this->assertContains('Access-Control-Request-Method', $header['vary']); - - // Make sure we have etag caching enabled - $this->assertArrayHasKey('etag', $header); - } - - public function testGetPersonRoles() - { - $client = $this->withUser('foobar', ['ROLE'], '42'); - $user = $this->getUser($client); - $this->withPerson($client, $user); - $response = $client->request('GET', '/people/foobar', ['headers' => [ - 'Authorization' => 'Bearer 42', - ]]); - $data = json_decode($response->getContent(), true, 512, JSON_THROW_ON_ERROR); - $this->assertEquals(['ROLE'], $data['roles']); - } - public function testAuthChecks() { $client = self::createClient(); $endpoints = [ - '/people', - '/people/foo', // FIXME: '/people/foo/organizations', '/organizations', '/organizations/foo', diff --git a/tests/Kernel.php b/tests/Kernel.php index a3d2e08..3ecdae2 100644 --- a/tests/Kernel.php +++ b/tests/Kernel.php @@ -2,10 +2,11 @@ declare(strict_types=1); -namespace Dbp\Relay\BaseBundle\Tests; +namespace Dbp\Relay\BaseOrganizationBundle\Tests; use ApiPlatform\Core\Bridge\Symfony\Bundle\ApiPlatformBundle; -use Dbp\Relay\BaseBundle\DbpRelayBaseBundle; +use Dbp\Relay\BaseOrganizationBundle\DbpRelayBaseOrganizationBundle; +use Dbp\Relay\BasePersonBundle\DbpRelayBasePersonBundle; use Dbp\Relay\CoreBundle\DbpRelayCoreBundle; use Nelmio\CorsBundle\NelmioCorsBundle; use Symfony\Bundle\FrameworkBundle\FrameworkBundle; @@ -29,7 +30,8 @@ class Kernel extends BaseKernel yield new NelmioCorsBundle(); yield new MonologBundle(); yield new ApiPlatformBundle(); - yield new DbpRelayBaseBundle(); + yield new DbpRelayBasePersonBundle(); + yield new DbpRelayBaseOrganizationBundle(); yield new DbpRelayCoreBundle(); } diff --git a/tests/OrganizationTest.php b/tests/OrganizationTest.php index ca85957..74b5ef6 100644 --- a/tests/OrganizationTest.php +++ b/tests/OrganizationTest.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace Dbp\Relay\BaseBundle\Tests; +namespace Dbp\Relay\BaseOrganizationBundle\Tests; -use Dbp\Relay\BaseBundle\Entity\Organization; +use Dbp\Relay\BaseOrganizationBundle\Entity\Organization; use PHPUnit\Framework\TestCase; class OrganizationTest extends TestCase diff --git a/tests/PersonTest.php b/tests/PersonTest.php deleted file mode 100644 index c9eae11..0000000 --- a/tests/PersonTest.php +++ /dev/null @@ -1,30 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Dbp\Relay\BaseBundle\Tests; - -use Dbp\Relay\BaseBundle\Entity\Person; -use PHPUnit\Framework\TestCase; - -class PersonTest extends TestCase -{ - public function testExtraData() - { - $person = new Person(); - - $person->setExtraData('foo', 42); - $this->assertSame(42, $person->getExtraData('foo')); - - $person->setExtraData('foo', [1]); - $this->assertSame([1], $person->getExtraData('foo')); - - $this->assertSame(null, $person->getExtraData('nope')); - } - - public function testRoles() - { - $person = new Person(); - $this->assertSame([], $person->getRoles()); - } -} -- GitLab