diff --git a/src/config/sync/search_api.index.concernements.yml b/src/config/sync/search_api.index.concernements.yml index bc570b3..7bafebd 100644 --- a/src/config/sync/search_api.index.concernements.yml +++ b/src/config/sync/search_api.index.concernements.yml @@ -118,7 +118,8 @@ field_settings: label: Title datasource_id: 'entity:node' property_path: title - type: string + type: text + boost: !!float 2 dependencies: module: - node @@ -126,7 +127,7 @@ field_settings: label: Title datasource_id: 'entity:node' property_path: title - type: string + type: text dependencies: module: - node @@ -134,7 +135,7 @@ field_settings: label: 'Entités » Paragraph » Entité » Contenu » Title' datasource_id: 'entity:node' property_path: 'field_entite:entity:field_entite:entity:title' - type: string + type: text dependencies: config: - field.storage.node.field_entite diff --git a/src/config/sync/search_api.index.entites.yml b/src/config/sync/search_api.index.entites.yml index 1588e27..af5ab6b 100644 --- a/src/config/sync/search_api.index.entites.yml +++ b/src/config/sync/search_api.index.entites.yml @@ -30,7 +30,7 @@ field_settings: label: 'Experiences vécues » Paragraph » Liens' datasource_id: 'entity:node' property_path: 'field_sources:entity:field_liens' - type: string + type: text dependencies: config: - field.storage.node.field_sources @@ -85,7 +85,8 @@ field_settings: label: Title datasource_id: 'entity:node' property_path: title - type: string + type: text + boost: !!float 2 dependencies: module: - node diff --git a/src/web/modules/custom/ouatt_graphql/graphql/ouatt_extension.base.graphqls b/src/web/modules/custom/ouatt_graphql/graphql/ouatt_extension.base.graphqls index d027f98..5b76378 100644 --- a/src/web/modules/custom/ouatt_graphql/graphql/ouatt_extension.base.graphqls +++ b/src/web/modules/custom/ouatt_graphql/graphql/ouatt_extension.base.graphqls @@ -50,6 +50,7 @@ type Entite implements NodeInterface { proximite: [Entite] agissante: Boolean sources: [Source] + concernement: Concernement } type Source { diff --git a/src/web/modules/custom/ouatt_graphql/src/Plugin/GraphQL/SchemaExtension/OuattSchemaExtension.php b/src/web/modules/custom/ouatt_graphql/src/Plugin/GraphQL/SchemaExtension/OuattSchemaExtension.php index f77dfea..5f19709 100644 --- a/src/web/modules/custom/ouatt_graphql/src/Plugin/GraphQL/SchemaExtension/OuattSchemaExtension.php +++ b/src/web/modules/custom/ouatt_graphql/src/Plugin/GraphQL/SchemaExtension/OuattSchemaExtension.php @@ -485,6 +485,38 @@ class OuattSchemaExtension extends SdlSchemaExtensionPluginBase { ->map('field', $builder->fromValue('field_sources')) ); + $registry->addFieldResolver('Entite', 'concernement', + $builder->compose( + $builder->callback(function($parent, $arg){ + $entite_nid = $parent->id(); + $node_storage = \Drupal::entityTypeManager()->getStorage('node'); + $paragraph_storage = \Drupal::entityTypeManager()->getStorage('paragraph'); + $query = $node_storage->getQuery() + ->condition('type', ['concernement'], 'IN') + // ->condition('uid', $parent->id()) + ->accessCheck(TRUE); + $results = $query->execute(); + $concernements = []; + foreach ($results as $nid) { + $concernement = $node_storage->load($nid); + $entite_integre_paragraph_values = $concernement->field_entite->getValue(); + foreach ($entite_integre_paragraph_values as $paragraph_ids) { + $paragraph = $paragraph_storage->load($paragraph_ids['target_id']); + $field_entite_values = $paragraph->field_entite->getValue(); + if ($field_entite_values[0]['target_id'] === $entite_nid) { + $concernements[] = $nid; + break; + } + } + } + return $concernements[0]; + }), + $builder->produce('entity_load') + ->map('type', $builder->fromValue('node')) + ->map('id', $builder->fromParent()) + ) + ); + } // ____