Loading modules/jsonapi_event_dispatcher/src/Event/JsonApiEntityFieldFilterAccessEvent.php +2 −2 Original line number Diff line number Diff line Loading @@ -8,7 +8,7 @@ use Drupal\Core\Session\AccountInterface; use Drupal\hook_event_dispatcher\Event\AccessEventInterface; use Drupal\hook_event_dispatcher\Event\AccessEventTrait; use Drupal\hook_event_dispatcher\Event\EventInterface; use Drupal\hook_event_dispatcher\HookEventDispatcherInterface; use Drupal\jsonapi_event_dispatcher\JsonApiHookEvents; /** * Class JsonApiEntityFieldFilterAccessEvent. Loading Loading @@ -51,7 +51,7 @@ class JsonApiEntityFieldFilterAccessEvent extends Event implements EventInterfac * {@inheritdoc} */ public function getDispatcherType(): string { return HookEventDispatcherInterface::JSONAPI_ENTITY_FIELD_FILTER_ACCESS; return JsonApiHookEvents::JSONAPI_ENTITY_FIELD_FILTER_ACCESS; } } modules/jsonapi_event_dispatcher/src/Event/JsonApiEntityFilterAccessEvent.php +2 −2 Original line number Diff line number Diff line Loading @@ -8,7 +8,7 @@ use Drupal\Core\Access\AccessResultInterface; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Session\AccountInterface; use Drupal\hook_event_dispatcher\Event\EventInterface; use Drupal\hook_event_dispatcher\HookEventDispatcherInterface; use Drupal\jsonapi_event_dispatcher\JsonApiHookEvents; /** * Class JsonapiEntityFilterAccessEvent. Loading Loading @@ -94,7 +94,7 @@ class JsonApiEntityFilterAccessEvent extends Event implements EventInterface { * {@inheritdoc} */ public function getDispatcherType(): string { return HookEventDispatcherInterface::JSONAPI_ENTITY_FILTER_ACCESS; return JsonApiHookEvents::JSONAPI_ENTITY_FILTER_ACCESS; } } modules/jsonapi_event_dispatcher/src/JsonApiHookEvents.php 0 → 100644 +38 −0 Original line number Diff line number Diff line <?php namespace Drupal\jsonapi_event_dispatcher; use Drupal\hook_event_dispatcher\HookEventDispatcherInterface; /** * Defines events for jsonapi hooks. */ final class JsonApiHookEvents { /** * Controls access when filtering by entity data via JSON:API. * * @Event * * @see \Drupal\jsonapi_event_dispatcher\Event\JsonApiEntityFilterAccessEvent * @see jsonapi_event_dispatcher_jsonapi_entity_filter_access() * @see hook_jsonapi_entity_filter_access() * * @var string */ public const JSONAPI_ENTITY_FILTER_ACCESS = HookEventDispatcherInterface::PREFIX . 'jsonapi.entity_filter_access'; /** * Restricts filtering access to the given field. * * @Event * * @see \Drupal\jsonapi_event_dispatcher\Event\JsonApiEntityFieldFilterAccessEvent * @see jsonapi_event_dispatcher_jsonapi_entity_field_filter_access() * @see hook_jsonapi_entity_field_filter_access() * * @var string */ public const JSONAPI_ENTITY_FIELD_FILTER_ACCESS = HookEventDispatcherInterface::PREFIX . 'jsonapi.entity_field_filter_access'; } modules/jsonapi_event_dispatcher/tests/src/Kernel/JsonApiEntityFieldFilterAccessEventTest.php +2 −2 Original line number Diff line number Diff line Loading @@ -3,8 +3,8 @@ namespace Drupal\Tests\jsonapi_event_dispatcher\Kernel; use Drupal\Core\Access\AccessResult; use Drupal\hook_event_dispatcher\HookEventDispatcherInterface; use Drupal\jsonapi_event_dispatcher\Event\JsonApiEntityFieldFilterAccessEvent; use Drupal\jsonapi_event_dispatcher\JsonApiHookEvents; use Drupal\KernelTests\KernelTestBase; use Drupal\Tests\hook_event_dispatcher\Kernel\ListenerTrait; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; Loading Loading @@ -80,7 +80,7 @@ class JsonApiEntityFieldFilterAccessEventTest extends KernelTestBase { $this->expectException($exception); } $this->listen(HookEventDispatcherInterface::JSONAPI_ENTITY_FIELD_FILTER_ACCESS, 'onJsonapiEntityFieldFilterAccess'); $this->listen(JsonApiHookEvents::JSONAPI_ENTITY_FIELD_FILTER_ACCESS, 'onJsonapiEntityFieldFilterAccess'); $repository = $this->container->get('jsonapi.resource_type.repository'); $path = $this->container->get('jsonapi.field_resolver')->resolveInternalEntityQueryPath($repository->get('entity_test', 'entity_test'), $fieldName); Loading modules/jsonapi_event_dispatcher/tests/src/Kernel/JsonApiEntityFilterAccessEventTest.php +2 −2 Original line number Diff line number Diff line Loading @@ -4,11 +4,11 @@ namespace Drupal\Tests\jsonapi_event_dispatcher\Kernel; use Drupal\Core\Access\AccessResult; use Drupal\Core\Entity\EntityInterface; use Drupal\hook_event_dispatcher\HookEventDispatcherInterface; use Drupal\jsonapi\JsonApiResource\Data; use Drupal\jsonapi\JsonApiResource\JsonApiDocumentTopLevel; use Drupal\jsonapi\ResourceType\ResourceType; use Drupal\jsonapi_event_dispatcher\Event\JsonApiEntityFilterAccessEvent; use Drupal\jsonapi_event_dispatcher\JsonApiHookEvents; use Drupal\KernelTests\KernelTestBase; use Drupal\Tests\hook_event_dispatcher\Kernel\ListenerTrait; use Drupal\Tests\user\Traits\UserCreationTrait; Loading Loading @@ -49,7 +49,7 @@ class JsonApiEntityFilterAccessEventTest extends KernelTestBase { * @throws \Exception */ public function testJsonapiEntityFilterAccessEvent(): void { $this->listen(HookEventDispatcherInterface::JSONAPI_ENTITY_FILTER_ACCESS, 'onJsonapiEntityFilterAccess'); $this->listen(JsonApiHookEvents::JSONAPI_ENTITY_FILTER_ACCESS, 'onJsonapiEntityFilterAccess'); $this->setUpCurrentUser([], ['view test entity']); $entity = $this->createEntity(); Loading Loading
modules/jsonapi_event_dispatcher/src/Event/JsonApiEntityFieldFilterAccessEvent.php +2 −2 Original line number Diff line number Diff line Loading @@ -8,7 +8,7 @@ use Drupal\Core\Session\AccountInterface; use Drupal\hook_event_dispatcher\Event\AccessEventInterface; use Drupal\hook_event_dispatcher\Event\AccessEventTrait; use Drupal\hook_event_dispatcher\Event\EventInterface; use Drupal\hook_event_dispatcher\HookEventDispatcherInterface; use Drupal\jsonapi_event_dispatcher\JsonApiHookEvents; /** * Class JsonApiEntityFieldFilterAccessEvent. Loading Loading @@ -51,7 +51,7 @@ class JsonApiEntityFieldFilterAccessEvent extends Event implements EventInterfac * {@inheritdoc} */ public function getDispatcherType(): string { return HookEventDispatcherInterface::JSONAPI_ENTITY_FIELD_FILTER_ACCESS; return JsonApiHookEvents::JSONAPI_ENTITY_FIELD_FILTER_ACCESS; } }
modules/jsonapi_event_dispatcher/src/Event/JsonApiEntityFilterAccessEvent.php +2 −2 Original line number Diff line number Diff line Loading @@ -8,7 +8,7 @@ use Drupal\Core\Access\AccessResultInterface; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Session\AccountInterface; use Drupal\hook_event_dispatcher\Event\EventInterface; use Drupal\hook_event_dispatcher\HookEventDispatcherInterface; use Drupal\jsonapi_event_dispatcher\JsonApiHookEvents; /** * Class JsonapiEntityFilterAccessEvent. Loading Loading @@ -94,7 +94,7 @@ class JsonApiEntityFilterAccessEvent extends Event implements EventInterface { * {@inheritdoc} */ public function getDispatcherType(): string { return HookEventDispatcherInterface::JSONAPI_ENTITY_FILTER_ACCESS; return JsonApiHookEvents::JSONAPI_ENTITY_FILTER_ACCESS; } }
modules/jsonapi_event_dispatcher/src/JsonApiHookEvents.php 0 → 100644 +38 −0 Original line number Diff line number Diff line <?php namespace Drupal\jsonapi_event_dispatcher; use Drupal\hook_event_dispatcher\HookEventDispatcherInterface; /** * Defines events for jsonapi hooks. */ final class JsonApiHookEvents { /** * Controls access when filtering by entity data via JSON:API. * * @Event * * @see \Drupal\jsonapi_event_dispatcher\Event\JsonApiEntityFilterAccessEvent * @see jsonapi_event_dispatcher_jsonapi_entity_filter_access() * @see hook_jsonapi_entity_filter_access() * * @var string */ public const JSONAPI_ENTITY_FILTER_ACCESS = HookEventDispatcherInterface::PREFIX . 'jsonapi.entity_filter_access'; /** * Restricts filtering access to the given field. * * @Event * * @see \Drupal\jsonapi_event_dispatcher\Event\JsonApiEntityFieldFilterAccessEvent * @see jsonapi_event_dispatcher_jsonapi_entity_field_filter_access() * @see hook_jsonapi_entity_field_filter_access() * * @var string */ public const JSONAPI_ENTITY_FIELD_FILTER_ACCESS = HookEventDispatcherInterface::PREFIX . 'jsonapi.entity_field_filter_access'; }
modules/jsonapi_event_dispatcher/tests/src/Kernel/JsonApiEntityFieldFilterAccessEventTest.php +2 −2 Original line number Diff line number Diff line Loading @@ -3,8 +3,8 @@ namespace Drupal\Tests\jsonapi_event_dispatcher\Kernel; use Drupal\Core\Access\AccessResult; use Drupal\hook_event_dispatcher\HookEventDispatcherInterface; use Drupal\jsonapi_event_dispatcher\Event\JsonApiEntityFieldFilterAccessEvent; use Drupal\jsonapi_event_dispatcher\JsonApiHookEvents; use Drupal\KernelTests\KernelTestBase; use Drupal\Tests\hook_event_dispatcher\Kernel\ListenerTrait; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; Loading Loading @@ -80,7 +80,7 @@ class JsonApiEntityFieldFilterAccessEventTest extends KernelTestBase { $this->expectException($exception); } $this->listen(HookEventDispatcherInterface::JSONAPI_ENTITY_FIELD_FILTER_ACCESS, 'onJsonapiEntityFieldFilterAccess'); $this->listen(JsonApiHookEvents::JSONAPI_ENTITY_FIELD_FILTER_ACCESS, 'onJsonapiEntityFieldFilterAccess'); $repository = $this->container->get('jsonapi.resource_type.repository'); $path = $this->container->get('jsonapi.field_resolver')->resolveInternalEntityQueryPath($repository->get('entity_test', 'entity_test'), $fieldName); Loading
modules/jsonapi_event_dispatcher/tests/src/Kernel/JsonApiEntityFilterAccessEventTest.php +2 −2 Original line number Diff line number Diff line Loading @@ -4,11 +4,11 @@ namespace Drupal\Tests\jsonapi_event_dispatcher\Kernel; use Drupal\Core\Access\AccessResult; use Drupal\Core\Entity\EntityInterface; use Drupal\hook_event_dispatcher\HookEventDispatcherInterface; use Drupal\jsonapi\JsonApiResource\Data; use Drupal\jsonapi\JsonApiResource\JsonApiDocumentTopLevel; use Drupal\jsonapi\ResourceType\ResourceType; use Drupal\jsonapi_event_dispatcher\Event\JsonApiEntityFilterAccessEvent; use Drupal\jsonapi_event_dispatcher\JsonApiHookEvents; use Drupal\KernelTests\KernelTestBase; use Drupal\Tests\hook_event_dispatcher\Kernel\ListenerTrait; use Drupal\Tests\user\Traits\UserCreationTrait; Loading Loading @@ -49,7 +49,7 @@ class JsonApiEntityFilterAccessEventTest extends KernelTestBase { * @throws \Exception */ public function testJsonapiEntityFilterAccessEvent(): void { $this->listen(HookEventDispatcherInterface::JSONAPI_ENTITY_FILTER_ACCESS, 'onJsonapiEntityFilterAccess'); $this->listen(JsonApiHookEvents::JSONAPI_ENTITY_FILTER_ACCESS, 'onJsonapiEntityFilterAccess'); $this->setUpCurrentUser([], ['view test entity']); $entity = $this->createEntity(); Loading