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..3649c5f610260b8cd739e22474f8af42dd99a2ef 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..981e1d17f4d5292f826abd26cdab36cace927c5d 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..aeae83cd7eb6927f94f00118101ca968ddf49355 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..cc7c19f02cde5681b658887f56ef4215b7ebca13 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..7a29e4a8619cc09ce64e0cf53d41ef55631a01c2 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; @@ -6,9 +8,9 @@ use Drupal\Core\Cache\CacheableMetadata; use Drupal\Core\Entity\Query\QueryInterface; use Drupal\Core\Entity\RevisionableStorageInterface; use Drupal\jsonapi\JsonApiResource\ResourceObjectData; +use Drupal\jsonapi_resources\Entity\Query\PaginatorInterface; use Drupal\jsonapi_resources\Unstable\Entity\Query\CacheabilityCapturingExecutor; use Drupal\jsonapi_resources\Unstable\Entity\Query\Pagination\OffsetLimitPaginator; -use Drupal\jsonapi_resources\Entity\Query\PaginatorInterface; use Symfony\Component\HttpFoundation\Request; /** diff --git a/src/Resource/EntityResourceBase.php b/src/Resource/EntityResourceBase.php index 069883d66b29fb63dfa4af7711c785acdaecf25e..af7aacfd240169cba3f7f1dfa18ceeef840c5e5c 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..dd6b62799de4646019d0b118ed9a26050562983c 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..14acf195772a509122b2e294e0c87bc49f01a9b0 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..ed97163aa0b00582ff919d7b52ce9b6e8dcb2536 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..8ad9603dc7430d4c2fe6bbf23361a347b28fb466 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..6a7b08e30d35159f103e941a2bc998ced0df4163 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..cd92e53cd50a9effc0e891d79758e66b08bc977b 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..a1b3bf800fc42ebdb50a90c3b6c4d3889f2709cd 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..38815b0d7f2c9799efcc04f1a1964a2b5193837d 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..d0aeeaa2f89950673004a576512230c33748791d 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..b1d96c79ca4cd98a192ce5a426a0852b0c834c48 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..e8cfa5ab5a30b50fc83bb612b38947d5796ebc17 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..e4222f8e2693c1619fe5d9f9f6dfdc3cad040f34 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..47cbd265bb94dd77fc606c0f2831276f3738315e 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/Routing/ResourceRoutes.php b/src/Unstable/Routing/ResourceRoutes.php index 6c40d3b3a3c0577fee412b350c5ae8a7410c3cf2..b6fd8a9122f218e9cc64a659459ee93198673da0 100644 --- a/src/Unstable/Routing/ResourceRoutes.php +++ b/src/Unstable/Routing/ResourceRoutes.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Drupal\jsonapi_resources\Unstable\Routing; use Drupal\Core\Routing\RouteBuildEvent; diff --git a/src/Unstable/Value/NewResourceObject.php b/src/Unstable/Value/NewResourceObject.php index 621c058546d961ca73d2ecbdf719ba5aa1d9762d..276b5c66f6a17d7ed2e5fca29cc6055274bab324 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..0bf5a9b5e035ae3752aa1a147abd59c91c187c36 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; diff --git a/tests/src/Unit/Routing/ResourceRoutesTest.php b/tests/src/Unit/Routing/ResourceRoutesTest.php index 0b69631364f30a309ae1e478de8b47dab3407ef2..16d6d5e4474f19ff00f6bb3c654e47c6c904981f 100644 --- a/tests/src/Unit/Routing/ResourceRoutesTest.php +++ b/tests/src/Unit/Routing/ResourceRoutesTest.php @@ -1,6 +1,6 @@ <?php -declare(strict_types = 1); +declare(strict_types=1); namespace Drupal\Tests\jsonapi_resources\Unit\Routing;