Преглед на файлове

update allmapitemsof with fake creation family id

axolotle преди 2 години
родител
ревизия
248304b461
променени са 1 файла, в които са добавени 12 реда и са изтрити 4 реда
  1. 12 4
      src/web/modules/custom/enfrancais_graphql/src/Plugin/GraphQL/SchemaExtension/EnFrSchemaExtension.php

+ 12 - 4
src/web/modules/custom/enfrancais_graphql/src/Plugin/GraphQL/SchemaExtension/EnFrSchemaExtension.php

@@ -210,10 +210,18 @@ class EnFrSchemaExtension extends SdlSchemaExtensionPluginBase {
       $builder->compose(
           $builder->callback(function($parent, $arg){
             $entity_storage = \Drupal::entityTypeManager()->getStorage('node');
-            $query = $entity_storage->getQuery()
-              ->condition('type', ['texte', 'texte_prod'], 'IN')
-              ->condition('field_famille', $arg)
-              ->accessCheck(TRUE);
+            $query = $entity_storage->getQuery();
+            // creations have no family, return creation for id == 0
+            if ($arg['familyId'] == 0) {
+              $query
+                ->condition('type', ['creation'], 'IN')
+                ->accessCheck(TRUE);
+            } else {
+              $query
+                ->condition('type', ['texte', 'texte_prod'], 'IN')
+                ->condition('field_famille', $arg)
+                ->accessCheck(TRUE);
+            }
             $results = $query->execute();
             return $results;
           }),