diff --git a/README.md b/README.md index 89be98803af0106517ffcfdb09babec39e793684..e1aede487b66701968b30f96e19747b10c2dc182 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # JSON:API Resources -This module let's you define custom resources at routes of your choice that use existing resource types. This is useful -for defining routes that return resource objects based on context like the currently authenticated user instead of a +This module let's you define custom resources at routes of your choice that use +existing resource types. This is useful for defining routes that return resource + objects based on context like the currently authenticated user instead of a route parameter (e.g. a UUID) diff --git a/src/Entity/Query/PaginatorInterface.php b/src/Entity/Query/PaginatorInterface.php index b8ab6e222982263a07feca88938afc893f1407f8..170eafafba744e9a4a1740cd1453f5bda345fede 100644 --- a/src/Entity/Query/PaginatorInterface.php +++ b/src/Entity/Query/PaginatorInterface.php @@ -1,4 +1,6 @@ -<?php declare(strict_types = 1); +<?php + +declare(strict_types = 1); namespace Drupal\jsonapi_resources\Entity\Query; diff --git a/src/Entity/Query/PaginatorMetadata.php b/src/Entity/Query/PaginatorMetadata.php index 2316df93878c0d14056c042653039fb1f2872904..3eaf9a0690a404123fe9db260ea81b2789671dcb 100644 --- a/src/Entity/Query/PaginatorMetadata.php +++ b/src/Entity/Query/PaginatorMetadata.php @@ -1,4 +1,6 @@ -<?php declare(strict_types = 1); +<?php + +declare(strict_types = 1); namespace Drupal\jsonapi_resources\Entity\Query; diff --git a/src/Exception/ResourceImplementationException.php b/src/Exception/ResourceImplementationException.php index e6fd3bb070394bf03e76e93a5ab76c7ad45d2bd6..aa51f98dd2b8caa66bb9ea1a68b9dd23bbe135dd 100644 --- a/src/Exception/ResourceImplementationException.php +++ b/src/Exception/ResourceImplementationException.php @@ -1,4 +1,6 @@ -<?php declare(strict_types = 1); +<?php + +declare(strict_types = 1); namespace Drupal\jsonapi_resources\Exception; diff --git a/src/Exception/RouteDefinitionException.php b/src/Exception/RouteDefinitionException.php index ebff5c7f2e5ecfafe0d00a8f2a58c55f1d90420d..bdf6b6359e7a654be75dd9e17fbd30f74bc10e40 100644 --- a/src/Exception/RouteDefinitionException.php +++ b/src/Exception/RouteDefinitionException.php @@ -1,4 +1,6 @@ -<?php declare(strict_types = 1); +<?php + +declare(strict_types = 1); namespace Drupal\jsonapi_resources\Exception; diff --git a/src/Resource/EntityQueryResourceBase.php b/src/Resource/EntityQueryResourceBase.php index 9cab3d622767ccf33f7f014f6795b5c0d826e121..535085f17fd4c8309d1a2281530879c68cd40df9 100644 --- a/src/Resource/EntityQueryResourceBase.php +++ b/src/Resource/EntityQueryResourceBase.php @@ -1,4 +1,6 @@ -<?php declare(strict_types = 1); +<?php + +declare(strict_types = 1); namespace Drupal\jsonapi_resources\Resource; diff --git a/src/Resource/EntityResourceBase.php b/src/Resource/EntityResourceBase.php index 069883d66b29fb63dfa4af7711c785acdaecf25e..79c45efdd127abe32587d78a2c228749170a881d 100644 --- a/src/Resource/EntityResourceBase.php +++ b/src/Resource/EntityResourceBase.php @@ -1,4 +1,6 @@ -<?php declare(strict_types = 1); +<?php + +declare(strict_types = 1); namespace Drupal\jsonapi_resources\Resource; diff --git a/src/Resource/ResourceBase.php b/src/Resource/ResourceBase.php index 68874d9a8bb1c51c236e324faaa80cf89d7dff77..51695518e55d7e2b8095105ac021ccf1b371063b 100644 --- a/src/Resource/ResourceBase.php +++ b/src/Resource/ResourceBase.php @@ -1,4 +1,6 @@ -<?php declare(strict_types = 1); +<?php + +declare(strict_types = 1); namespace Drupal\jsonapi_resources\Resource; @@ -115,7 +117,7 @@ abstract class ResourceBase { return array_map(function ($resource_type_name) use ($route_name) { $resource_type = $this->resourceTypeRepository->getByTypeName($resource_type_name); if (is_null($resource_type)) { - // @todo: try to move this exception into Drupal\jsonapi_resources\Routing\ResourceRoutes::ensureResourceImplementationValid(). + // @todo Try to move this exception into Drupal\jsonapi_resources\Routing\ResourceRoutes::ensureResourceImplementationValid(). throw new RouteDefinitionException("The $route_name route definition's _jsonapi_resource_types route default declares the resource type $resource_type_name but a resource type by that name does not exist."); } return $resource_type; diff --git a/src/Unstable/Controller/ArgumentResolver/DocumentResolver.php b/src/Unstable/Controller/ArgumentResolver/DocumentResolver.php index 7e61e2a185a1c6ba3e0276edaa8c523070c4060d..955ed648e618467954a46520ccdd1b8b7d00b67a 100644 --- a/src/Unstable/Controller/ArgumentResolver/DocumentResolver.php +++ b/src/Unstable/Controller/ArgumentResolver/DocumentResolver.php @@ -1,4 +1,6 @@ -<?php declare(strict_types = 1); +<?php + +declare(strict_types = 1); namespace Drupal\jsonapi_resources\Unstable\Controller\ArgumentResolver; diff --git a/src/Unstable/Controller/JsonapiResourceController.php b/src/Unstable/Controller/JsonapiResourceController.php index 945792eef7ca50844595141999c526cb64543c4e..640b6fefde16ff08817979394f75ce5b79c74cde 100644 --- a/src/Unstable/Controller/JsonapiResourceController.php +++ b/src/Unstable/Controller/JsonapiResourceController.php @@ -1,4 +1,6 @@ -<?php declare(strict_types = 1); +<?php + +declare(strict_types = 1); namespace Drupal\jsonapi_resources\Unstable\Controller; diff --git a/src/Unstable/DependencyInjection/JsonapiResourceClassResolver.php b/src/Unstable/DependencyInjection/JsonapiResourceClassResolver.php index feabb065c4f56dc2ab92fd10f8a410969fc2c7ff..87aaa89dc7e29d0cd581effc4a3794315ed4e35a 100644 --- a/src/Unstable/DependencyInjection/JsonapiResourceClassResolver.php +++ b/src/Unstable/DependencyInjection/JsonapiResourceClassResolver.php @@ -1,4 +1,6 @@ -<?php declare(strict_types = 1); +<?php + +declare(strict_types = 1); namespace Drupal\jsonapi_resources\Unstable\DependencyInjection; diff --git a/src/Unstable/DocumentExtractor.php b/src/Unstable/DocumentExtractor.php index 2b4be6d169ad887b6c1db3916b31b6de479f4faa..1364a9656db2fd16b84876f3a34c0c75d7bbc5cd 100644 --- a/src/Unstable/DocumentExtractor.php +++ b/src/Unstable/DocumentExtractor.php @@ -1,4 +1,6 @@ -<?php declare(strict_types = 1); +<?php + +declare(strict_types = 1); namespace Drupal\jsonapi_resources\Unstable; diff --git a/src/Unstable/Entity/EntityCreationTrait.php b/src/Unstable/Entity/EntityCreationTrait.php index 470826efe79b41403cbb2f5bdd0b42b290a46d56..f5c9c37143c0d01558d86fb378466045af4d30a6 100644 --- a/src/Unstable/Entity/EntityCreationTrait.php +++ b/src/Unstable/Entity/EntityCreationTrait.php @@ -1,4 +1,6 @@ -<?php declare(strict_types = 1); +<?php + +declare(strict_types = 1); namespace Drupal\jsonapi_resources\Unstable\Entity; @@ -59,7 +61,7 @@ trait EntityCreationTrait { // Return a 409 Conflict response in accordance with the JSON:API spec. See // http://jsonapi.org/format/#crud-creating-responses-409. try { - // @todo: remove the assignment of the entity type manager to a variable when an "Aware" interface is added. + // @todo remove the assignment of the entity type manager to a variable when an "Aware" interface is added. /** @var \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager */ /** @var \Drupal\Core\Entity\EntityStorageInterface $entity_storage */ $entity_type_manager = $this->entityTypeManager; diff --git a/src/Unstable/Entity/Query/CacheabilityCapturingExecutor.php b/src/Unstable/Entity/Query/CacheabilityCapturingExecutor.php index 7f9950ca9e590b9e434f223c8a00196c293ef80d..7271a45735a1601c4d5c23b1fa9e1f063c3d49a9 100644 --- a/src/Unstable/Entity/Query/CacheabilityCapturingExecutor.php +++ b/src/Unstable/Entity/Query/CacheabilityCapturingExecutor.php @@ -1,4 +1,6 @@ -<?php declare(strict_types = 1); +<?php + +declare(strict_types = 1); namespace Drupal\jsonapi_resources\Unstable\Entity\Query; diff --git a/src/Unstable/Entity/Query/Pagination/OffsetLimitPaginator.php b/src/Unstable/Entity/Query/Pagination/OffsetLimitPaginator.php index 09c98e030e0efda8ac6d0724662959ad88d14018..c46f2448351e4838f235a11f5a9da7e42c9dc11b 100644 --- a/src/Unstable/Entity/Query/Pagination/OffsetLimitPaginator.php +++ b/src/Unstable/Entity/Query/Pagination/OffsetLimitPaginator.php @@ -1,4 +1,6 @@ -<?php declare(strict_types = 1); +<?php + +declare(strict_types = 1); namespace Drupal\jsonapi_resources\Unstable\Entity\Query\Pagination; diff --git a/src/Unstable/Entity/ResourceObjectToEntityMapper.php b/src/Unstable/Entity/ResourceObjectToEntityMapper.php index be8580a6efd77f9a00ac8fc56f8a09a9afe91c52..79cc148b043e92b6d0774df292dca2b1e4104674 100644 --- a/src/Unstable/Entity/ResourceObjectToEntityMapper.php +++ b/src/Unstable/Entity/ResourceObjectToEntityMapper.php @@ -1,4 +1,6 @@ -<?php declare(strict_types = 1); +<?php + +declare(strict_types = 1); namespace Drupal\jsonapi_resources\Unstable\Entity; diff --git a/src/Unstable/Entity/ResourceObjectToEntityMapperAwareInterface.php b/src/Unstable/Entity/ResourceObjectToEntityMapperAwareInterface.php index 092146baed4e077f8f8755ec1b9ad45f2bdadb17..f09c4399de231c82a5d335d4615a93fdf4cde523 100644 --- a/src/Unstable/Entity/ResourceObjectToEntityMapperAwareInterface.php +++ b/src/Unstable/Entity/ResourceObjectToEntityMapperAwareInterface.php @@ -1,4 +1,6 @@ -<?php declare(strict_types = 1); +<?php + +declare(strict_types = 1); namespace Drupal\jsonapi_resources\Unstable\Entity; diff --git a/src/Unstable/Entity/ResourceObjectToEntityMapperAwareTrait.php b/src/Unstable/Entity/ResourceObjectToEntityMapperAwareTrait.php index 4f3df2de53d5a0a99bea58e4e65f026d77b7f58d..7fde3a6a0181a7110aeafcd982517dfb0b32621f 100644 --- a/src/Unstable/Entity/ResourceObjectToEntityMapperAwareTrait.php +++ b/src/Unstable/Entity/ResourceObjectToEntityMapperAwareTrait.php @@ -1,4 +1,6 @@ -<?php declare(strict_types = 1); +<?php + +declare(strict_types = 1); namespace Drupal\jsonapi_resources\Unstable\Entity; diff --git a/src/Unstable/ResourceResponseFactory.php b/src/Unstable/ResourceResponseFactory.php index d7509605afc9b63cf1892c4e10a68f5b3aab5c3b..8c3b7ef986e453509061bc15f69429b3da45cb92 100644 --- a/src/Unstable/ResourceResponseFactory.php +++ b/src/Unstable/ResourceResponseFactory.php @@ -1,4 +1,6 @@ -<?php declare(strict_types = 1); +<?php + +declare(strict_types = 1); namespace Drupal\jsonapi_resources\Unstable; diff --git a/src/Unstable/Routing/Enhancer/ResourceEnhancer.php b/src/Unstable/Routing/Enhancer/ResourceEnhancer.php index 020bd3e2fa3573ef6b9a3ff8cc8dddf64a19828b..98214e4f1d4ecd849435dafe71ca305d604286b3 100644 --- a/src/Unstable/Routing/Enhancer/ResourceEnhancer.php +++ b/src/Unstable/Routing/Enhancer/ResourceEnhancer.php @@ -1,4 +1,6 @@ -<?php declare(strict_types = 1); +<?php + +declare(strict_types = 1); namespace Drupal\jsonapi_resources\Unstable\Routing\Enhancer; diff --git a/src/Unstable/Value/NewResourceObject.php b/src/Unstable/Value/NewResourceObject.php index 621c058546d961ca73d2ecbdf719ba5aa1d9762d..d226e0c36d653ea9584093546b226adbfe4c53b9 100644 --- a/src/Unstable/Value/NewResourceObject.php +++ b/src/Unstable/Value/NewResourceObject.php @@ -1,4 +1,6 @@ -<?php declare(strict_types = 1); +<?php + +declare(strict_types = 1); namespace Drupal\jsonapi_resources\Unstable\Value; diff --git a/tests/modules/jsonapi_resources_test/jsonapi_resources_test.info.yml b/tests/modules/jsonapi_resources_test/jsonapi_resources_test.info.yml index 1d06945c071d87fd0d746f4a5ef67d28bb331824..45422e6459f2c30af8fda8cc0b275aa542fb5af1 100644 --- a/tests/modules/jsonapi_resources_test/jsonapi_resources_test.info.yml +++ b/tests/modules/jsonapi_resources_test/jsonapi_resources_test.info.yml @@ -1,4 +1,5 @@ name: 'JSON:API Resources test module' +description: "Tests for JSON:API Resources." type: module package: Testing dependencies: diff --git a/tests/modules/jsonapi_resources_test/src/Resource/CurrentUserInfo.php b/tests/modules/jsonapi_resources_test/src/Resource/CurrentUserInfo.php index 87b9b140fcc175bff3f89640be1446b9ca490275..bf6a5b8f285d53f032efceb9f7d55fdb94c904ec 100644 --- a/tests/modules/jsonapi_resources_test/src/Resource/CurrentUserInfo.php +++ b/tests/modules/jsonapi_resources_test/src/Resource/CurrentUserInfo.php @@ -119,12 +119,12 @@ class CurrentUserInfo extends ResourceBase implements ContainerInjectionInterfac public function getRouteResourceTypes(Route $route, string $route_name): array { $fields = [ 'displayName' => new ResourceTypeAttribute('displayName'), - // @todo: convert this to a ResourceTypeRelationship. + // @todo convert this to a ResourceTypeRelationship. 'roles' => new ResourceTypeAttribute('roles', NULL, TRUE, FALSE), 'token' => new ResourceTypeAttribute('token'), ]; $resource_type = new ResourceType('current_user', 'current_user', NULL, FALSE, TRUE, TRUE, FALSE, $fields); - // @todo: Add role entities as a relatable resource type. + // @todo Add role entities as a relatable resource type. $resource_type->setRelatableResourceTypes([]); return [$resource_type]; } diff --git a/tests/src/Kernel/Routing/ResourceEnhancerTest.php b/tests/src/Kernel/Routing/ResourceEnhancerTest.php index 096dd34b7d5b16a295453ac3dd82347ebc2940b1..01e2ecef46f4421c9bfc2158b90205b4d34417f8 100644 --- a/tests/src/Kernel/Routing/ResourceEnhancerTest.php +++ b/tests/src/Kernel/Routing/ResourceEnhancerTest.php @@ -1,4 +1,6 @@ -<?php declare(strict_types = 1); +<?php + +declare(strict_types = 1); namespace Drupal\Tests\jsonapi_resources\Kernel;