You are here

protected function ThunderSchemaExtensionPluginBase::resolveMediaInterfaceFields in Thunder 6.2.x

Add fields common to all media types.

Parameters

string $type: The type name.

1 call to ThunderSchemaExtensionPluginBase::resolveMediaInterfaceFields()
ThunderMediaSchemaExtension::resolveFields in modules/thunder_gqls/src/Plugin/GraphQL/SchemaExtension/ThunderMediaSchemaExtension.php
Add image media field resolvers.

File

modules/thunder_gqls/src/Plugin/GraphQL/SchemaExtension/ThunderSchemaExtensionPluginBase.php, line 185

Class

ThunderSchemaExtensionPluginBase
The base class for Thunder schema extension plugins.

Namespace

Drupal\thunder_gqls\Plugin\GraphQL\SchemaExtension

Code

protected function resolveMediaInterfaceFields(string $type) {
  $this
    ->resolveBaseFields($type, 'media');
  $this
    ->addFieldResolverIfNotExists($type, 'thumbnail', $this->builder
    ->produce('thunder_image')
    ->map('entity', $this->builder
    ->fromPath('entity', 'thumbnail.entity'))
    ->map('field', $this->builder
    ->fromPath('entity', 'thumbnail')));
  if ($this->dataProducerManager
    ->hasDefinition('media_expire_fallback_entity')) {
    $this
      ->addFieldResolverIfNotExists($type, 'fallbackMedia', $this->builder
      ->produce('media_expire_fallback_entity')
      ->map('entity', $this->builder
      ->fromParent()));
  }
}