You are here

public function JsonApiBuildSubscriber::applyResourceConfig in JSON:API Extras 8.3

Apply resource config through the event.

Parameters

\Drupal\jsonapi\ResourceType\ResourceTypeBuildEvent $event: The build event used to change the resources and fields.

Throws

\Drupal\Component\Plugin\Exception\PluginNotFoundException

File

src/EventSubscriber/JsonApiBuildSubscriber.php, line 50

Class

JsonApiBuildSubscriber
JSON API build subscriber that applies all changes from extra's to the API.

Namespace

Drupal\jsonapi_extras\EventSubscriber

Code

public function applyResourceConfig(ResourceTypeBuildEvent $event) {
  $resource_config = $this
    ->getResourceConfig($event
    ->getResourceTypeName());
  if ($resource_config instanceof NullJsonapiResourceConfig) {
    return;
  }
  if ($resource_config
    ->get('disabled')) {
    $event
      ->disableResourceType();
  }
  $this
    ->overrideFields($resource_config, $event);
}