|
@@ -485,6 +485,38 @@ class OuattSchemaExtension extends SdlSchemaExtensionPluginBase {
|
|
->map('field', $builder->fromValue('field_sources'))
|
|
->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())
|
|
|
|
+ )
|
|
|
|
+ );
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
// ____
|
|
// ____
|