|
@@ -42,6 +42,10 @@ class OuattSchemaExtension extends SdlSchemaExtensionPluginBase {
|
|
//
|
|
//
|
|
$this->addEtape($registry, $builder);
|
|
$this->addEtape($registry, $builder);
|
|
//
|
|
//
|
|
|
|
+ $this->addBesoin($registry, $builder);
|
|
|
|
+ //
|
|
|
|
+ $this->addReponse($registry, $builder);
|
|
|
|
+ //
|
|
$this->addStatic($registry, $builder);
|
|
$this->addStatic($registry, $builder);
|
|
//
|
|
//
|
|
$this->addGroup($registry, $builder);
|
|
$this->addGroup($registry, $builder);
|
|
@@ -82,6 +86,9 @@ class OuattSchemaExtension extends SdlSchemaExtensionPluginBase {
|
|
switch ($value->bundle()) {
|
|
switch ($value->bundle()) {
|
|
case 'concernement': return 'Concernement';
|
|
case 'concernement': return 'Concernement';
|
|
case 'entite': return 'Entite';
|
|
case 'entite': return 'Entite';
|
|
|
|
+ case 'besoin': return 'Besoin';
|
|
|
|
+ case 'reponse': return 'Reponse';
|
|
|
|
+ case 'static': return 'Static';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
throw new Error('Could not resolve content type.');
|
|
throw new Error('Could not resolve content type.');
|
|
@@ -222,6 +229,13 @@ class OuattSchemaExtension extends SdlSchemaExtensionPluginBase {
|
|
->map('entity', $builder->fromParent())
|
|
->map('entity', $builder->fromParent())
|
|
->map('field', $builder->fromValue('field_doleancer'))
|
|
->map('field', $builder->fromValue('field_doleancer'))
|
|
);
|
|
);
|
|
|
|
+
|
|
|
|
+ // besoins: [Besoin]
|
|
|
|
+ $registry->addFieldResolver('Concernement', 'besoins',
|
|
|
|
+ $builder->produce('entity_reference')
|
|
|
|
+ ->map('entity', $builder->fromParent())
|
|
|
|
+ ->map('field', $builder->fromValue('field_besoin'))
|
|
|
|
+ );
|
|
}
|
|
}
|
|
|
|
|
|
// _____ _ _ _ __ ___ _ __ __
|
|
// _____ _ _ _ __ ___ _ __ __
|
|
@@ -362,8 +376,7 @@ class OuattSchemaExtension extends SdlSchemaExtensionPluginBase {
|
|
->map('value', $builder->fromParent())
|
|
->map('value', $builder->fromParent())
|
|
->map('path', $builder->fromValue('field_entite_agissante.value'))
|
|
->map('path', $builder->fromValue('field_entite_agissante.value'))
|
|
);
|
|
);
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+
|
|
$registry->addFieldResolver('Entite', 'action',
|
|
$registry->addFieldResolver('Entite', 'action',
|
|
$builder->produce('property_path')
|
|
$builder->produce('property_path')
|
|
->map('type', $builder->fromValue('entity:node'))
|
|
->map('type', $builder->fromValue('entity:node'))
|
|
@@ -512,6 +525,206 @@ class OuattSchemaExtension extends SdlSchemaExtensionPluginBase {
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // ____ _
|
|
|
|
+ // | __ ) ___ ___ ___ (_)_ __
|
|
|
|
+ // | _ \ / _ \/ __|/ _ \| | '_ \
|
|
|
|
+ // | |_) | __/\__ \ (_) | | | | |
|
|
|
|
+ // |____/ \___||___/\___/|_|_| |_|
|
|
|
|
+ protected function addBesoin(ResolverRegistryInterface $registry, ResolverBuilder $builder) {
|
|
|
|
+ $registry->addFieldResolver('Query', 'allbesoins',
|
|
|
|
+ $builder->compose(
|
|
|
|
+ $builder->callback(function($parent, $arg){
|
|
|
|
+ $entity_storage = \Drupal::entityTypeManager()->getStorage('node');
|
|
|
|
+ $query = $entity_storage->getQuery()
|
|
|
|
+ ->condition('type', ['besoin'], 'IN')
|
|
|
|
+ ->accessCheck(TRUE);
|
|
|
|
+ $results = $query->execute();
|
|
|
|
+ return $results;
|
|
|
|
+ }),
|
|
|
|
+ $builder->produce('entity_load_multiple')
|
|
|
|
+ ->map('type', $builder->fromValue('node'))
|
|
|
|
+ ->map('ids', $builder->fromParent())
|
|
|
|
+ )
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ $registry->addFieldResolver('Query', 'besoins',
|
|
|
|
+ $builder->compose(
|
|
|
|
+ $builder->callback(function($parent, $arg){
|
|
|
|
+ $entity_storage = \Drupal::entityTypeManager()->getStorage('node');
|
|
|
|
+ $query = $entity_storage->getQuery()
|
|
|
|
+ ->condition('type', ['besoin'], 'IN')
|
|
|
|
+ ->accessCheck(TRUE);
|
|
|
|
+ $results = $query->execute();
|
|
|
|
+ return $results;
|
|
|
|
+ }),
|
|
|
|
+ $builder->produce('entity_load_multiple')
|
|
|
|
+ ->map('type', $builder->fromValue('node'))
|
|
|
|
+ ->map('ids', $builder->fromArgument('ids'))
|
|
|
|
+ )
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ $registry->addFieldResolver('Query', 'besoin',
|
|
|
|
+ $builder->produce('entity_load')
|
|
|
|
+ ->map('type', $builder->fromValue('node'))
|
|
|
|
+ ->map('id', $builder->fromArgument('id'))
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ // id: Int!
|
|
|
|
+ $registry->addFieldResolver('Besoin', 'id',
|
|
|
|
+ $builder->produce('entity_id')
|
|
|
|
+ ->map('entity', $builder->fromParent())
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ // path: String!
|
|
|
|
+ $registry->addFieldResolver('Besoin', 'path',
|
|
|
|
+ $builder->compose(
|
|
|
|
+ $builder->produce('entity_url')
|
|
|
|
+ ->map('entity', $builder->fromParent()),
|
|
|
|
+ $builder->produce('url_path')
|
|
|
|
+ ->map('url', $builder->fromParent())
|
|
|
|
+ )
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ // description: String!
|
|
|
|
+ $registry->addFieldResolver('Besoin', 'description',
|
|
|
|
+ $builder->produce('property_path')
|
|
|
|
+ ->map('type', $builder->fromValue('entity:node'))
|
|
|
|
+ ->map('value', $builder->fromParent())
|
|
|
|
+ ->map('path', $builder->fromValue('body.value'))
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ // index: Int
|
|
|
|
+ $registry->addFieldResolver('Besoin', 'index',
|
|
|
|
+ $builder->produce('property_path')
|
|
|
|
+ ->map('type', $builder->fromValue('entity:node'))
|
|
|
|
+ ->map('value', $builder->fromParent())
|
|
|
|
+ ->map('path', $builder->fromValue('field_index.value'))
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ // concernement: Concernement
|
|
|
|
+ $registry->addFieldResolver('Besoin', 'concernement',
|
|
|
|
+ $builder->compose(
|
|
|
|
+ $builder->produce('entity_reference')
|
|
|
|
+ ->map('entity', $builder->fromParent())
|
|
|
|
+ ->map('field', $builder->fromValue('field_concernement')),
|
|
|
|
+ $builder->callback(function($parent, $arg){
|
|
|
|
+ return $parent[0];
|
|
|
|
+ })
|
|
|
|
+ ));
|
|
|
|
+
|
|
|
|
+ // reponses: [Reponse]
|
|
|
|
+ $registry->addFieldResolver('Besoin', 'reponses',
|
|
|
|
+ $builder->produce('entity_reference')
|
|
|
|
+ ->map('entity', $builder->fromParent())
|
|
|
|
+ ->map('field', $builder->fromValue('field_reponse'))
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // ____
|
|
|
|
+ // | _ \ ___ _ __ ___ _ __ ___ ___
|
|
|
|
+ // | |_) / _ \ '_ \ / _ \| '_ \/ __|/ _ \
|
|
|
|
+ // | _ < __/ |_) | (_) | | | \__ \ __/
|
|
|
|
+ // |_| \_\___| .__/ \___/|_| |_|___/\___|
|
|
|
|
+ // |_|
|
|
|
|
+ protected function addReponse(ResolverRegistryInterface $registry, ResolverBuilder $builder) {
|
|
|
|
+ $registry->addFieldResolver('Query', 'allreponses',
|
|
|
|
+ $builder->compose(
|
|
|
|
+ $builder->callback(function($parent, $arg){
|
|
|
|
+ $entity_storage = \Drupal::entityTypeManager()->getStorage('node');
|
|
|
|
+ $query = $entity_storage->getQuery()
|
|
|
|
+ ->condition('type', ['reponse'], 'IN')
|
|
|
|
+ ->accessCheck(TRUE);
|
|
|
|
+ $results = $query->execute();
|
|
|
|
+ return $results;
|
|
|
|
+ }),
|
|
|
|
+ $builder->produce('entity_load_multiple')
|
|
|
|
+ ->map('type', $builder->fromValue('node'))
|
|
|
|
+ ->map('ids', $builder->fromParent())
|
|
|
|
+ )
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ $registry->addFieldResolver('Query', 'reponses',
|
|
|
|
+ $builder->compose(
|
|
|
|
+ $builder->callback(function($parent, $arg){
|
|
|
|
+ $entity_storage = \Drupal::entityTypeManager()->getStorage('node');
|
|
|
|
+ $query = $entity_storage->getQuery()
|
|
|
|
+ ->condition('type', ['reponse'], 'IN')
|
|
|
|
+ ->accessCheck(TRUE);
|
|
|
|
+ $results = $query->execute();
|
|
|
|
+ return $results;
|
|
|
|
+ }),
|
|
|
|
+ $builder->produce('entity_load_multiple')
|
|
|
|
+ ->map('type', $builder->fromValue('node'))
|
|
|
|
+ ->map('ids', $builder->fromArgument('ids'))
|
|
|
|
+ )
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ $registry->addFieldResolver('Query', 'reponse',
|
|
|
|
+ $builder->produce('entity_load')
|
|
|
|
+ ->map('type', $builder->fromValue('node'))
|
|
|
|
+ ->map('id', $builder->fromArgument('id'))
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ // id: Int!
|
|
|
|
+ $registry->addFieldResolver('Reponse', 'id',
|
|
|
|
+ $builder->produce('entity_id')
|
|
|
|
+ ->map('entity', $builder->fromParent())
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ // path: String!
|
|
|
|
+ $registry->addFieldResolver('Reponse', 'path',
|
|
|
|
+ $builder->compose(
|
|
|
|
+ $builder->produce('entity_url')
|
|
|
|
+ ->map('entity', $builder->fromParent()),
|
|
|
|
+ $builder->produce('url_path')
|
|
|
|
+ ->map('url', $builder->fromParent())
|
|
|
|
+ )
|
|
|
|
+ );
|
|
|
|
+ // besoin: Besoin
|
|
|
|
+ $registry->addFieldResolver('Reponse', 'besoin',
|
|
|
|
+ $builder->compose(
|
|
|
|
+ $builder->produce('entity_reference')
|
|
|
|
+ ->map('entity', $builder->fromParent())
|
|
|
|
+ ->map('field', $builder->fromValue('field_besoin_on_reponses')),
|
|
|
|
+ $builder->callback(function($parent, $arg){
|
|
|
|
+ return $parent[0];
|
|
|
|
+ })
|
|
|
|
+ ));
|
|
|
|
+
|
|
|
|
+ // qui: String
|
|
|
|
+ $registry->addFieldResolver('Reponse', 'qui',
|
|
|
|
+ $builder->produce('property_path')
|
|
|
|
+ ->map('type', $builder->fromValue('entity:node'))
|
|
|
|
+ ->map('value', $builder->fromParent())
|
|
|
|
+ ->map('path', $builder->fromValue('field_qui.value'))
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ // quoi: String
|
|
|
|
+ $registry->addFieldResolver('Reponse', 'quoi',
|
|
|
|
+ $builder->produce('property_path')
|
|
|
|
+ ->map('type', $builder->fromValue('entity:node'))
|
|
|
|
+ ->map('value', $builder->fromParent())
|
|
|
|
+ ->map('path', $builder->fromValue('field_quoi.value'))
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ // ou: String
|
|
|
|
+ $registry->addFieldResolver('Reponse', 'ou',
|
|
|
|
+ $builder->produce('property_path')
|
|
|
|
+ ->map('type', $builder->fromValue('entity:node'))
|
|
|
|
+ ->map('value', $builder->fromParent())
|
|
|
|
+ ->map('path', $builder->fromValue('field_ou.value'))
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ // avec: String
|
|
|
|
+ $registry->addFieldResolver('Reponse', 'avec',
|
|
|
|
+ $builder->produce('property_path')
|
|
|
|
+ ->map('type', $builder->fromValue('entity:node'))
|
|
|
|
+ ->map('value', $builder->fromParent())
|
|
|
|
+ ->map('path', $builder->fromValue('field_avec.value'))
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
// ___ _ _ _
|
|
// ___ _ _ _
|
|
// / __| |_ __ _| |_(_)__ ___
|
|
// / __| |_ __ _| |_(_)__ ___
|
|
// \__ \ _/ _` | _| / _(_-<
|
|
// \__ \ _/ _` | _| / _(_-<
|