|
@@ -0,0 +1,555 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace Drupal\enfrancais_graphql\Plugin\GraphQL\SchemaExtension;
|
|
|
+
|
|
|
+use Drupal\graphql\GraphQL\ResolverBuilder;
|
|
|
+use Drupal\graphql\GraphQL\ResolverRegistryInterface;
|
|
|
+use Drupal\graphql\GraphQL\Response\ResponseInterface;
|
|
|
+use Drupal\graphql\Plugin\GraphQL\SchemaExtension\SdlSchemaExtensionPluginBase;
|
|
|
+use Drupal\materio_graphql\GraphQL\Response\MaterioResponse;
|
|
|
+use Drupal\Core\Url;
|
|
|
+
|
|
|
+use GraphQL\Error\Error;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @SchemaExtension(
|
|
|
+ * id = "enfr_extension",
|
|
|
+ * name = "En Francais extension",
|
|
|
+ * description = "En Francais extension.",
|
|
|
+ * schema = "enfr"
|
|
|
+ * )
|
|
|
+ */
|
|
|
+class EnFrSchemaExtension extends SdlSchemaExtensionPluginBase {
|
|
|
+
|
|
|
+ /**
|
|
|
+ * {@inheritdoc}
|
|
|
+ */
|
|
|
+ public function registerResolvers(ResolverRegistryInterface $registry) {
|
|
|
+ $builder = new ResolverBuilder();
|
|
|
+
|
|
|
+ $this->addRouteResolver($registry, $builder);
|
|
|
+
|
|
|
+ $this->addTextref($registry, $builder);
|
|
|
+
|
|
|
+ $this->addTextprod($registry, $builder);
|
|
|
+ //
|
|
|
+ $this->addFilefield($registry, $builder);
|
|
|
+ //
|
|
|
+ $this->addFile($registry, $builder);
|
|
|
+ //
|
|
|
+ $this->addDate($registry, $builder);
|
|
|
+ //
|
|
|
+ $this->addVideolink($registry, $builder);
|
|
|
+ //
|
|
|
+ $this->addImage($registry, $builder);
|
|
|
+ //
|
|
|
+ $this->addTaxoterm($registry, $builder);
|
|
|
+ //
|
|
|
+ // $this->addNote($registry, $builder);
|
|
|
+ //
|
|
|
+ // $this->addSearchResult($registry, $builder);
|
|
|
+ //
|
|
|
+ // $this->addSample($registry, $builder);
|
|
|
+ //
|
|
|
+ // $this->addArticle($registry, $builder);
|
|
|
+ //
|
|
|
+ // $this->addThematique($registry, $builder);
|
|
|
+ //
|
|
|
+ // $this->addCompany($registry, $builder);
|
|
|
+ //
|
|
|
+ // $this->addProduct($registry, $builder);
|
|
|
+ //
|
|
|
+ // $this->addVariation($registry, $builder);
|
|
|
+ //
|
|
|
+ // $this->addPrice($registry, $builder);
|
|
|
+ //
|
|
|
+ // $this->addAddress($registry, $builder);
|
|
|
+ //
|
|
|
+ // $this->addLink($registry, $builder);
|
|
|
+ //
|
|
|
+ // $this->addShowroom($registry, $builder);
|
|
|
+ //
|
|
|
+ // $this->addThesaurus($registry, $builder);
|
|
|
+ //
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ // ___ _
|
|
|
+ // | _ \___ _ _| |_ ___
|
|
|
+ // | / _ \ || | _/ -_)
|
|
|
+ // |_|_\___/\_,_|\__\___|
|
|
|
+ protected function addRouteResolver(ResolverRegistryInterface $registry, ResolverBuilder $builder) {
|
|
|
+ // Tell GraphQL how to resolve types of a common interface.
|
|
|
+ $registry->addTypeResolver('NodeInterface', function ($value) {
|
|
|
+
|
|
|
+ $path = explode('\\', get_class($value));
|
|
|
+ $class = array_pop($path);
|
|
|
+
|
|
|
+ if ($class === 'Node') {
|
|
|
+ switch ($value->bundle()) {
|
|
|
+ case 'texte': return 'Textref';
|
|
|
+ case 'texte_prod': return 'TextProd';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ throw new Error('Could not resolve content type.');
|
|
|
+ });
|
|
|
+
|
|
|
+ $registry->addFieldResolver('Query', 'route',
|
|
|
+ $builder->compose(
|
|
|
+ $builder->produce('route_load')
|
|
|
+ ->map('path', $builder->fromArgument('path')),
|
|
|
+ $builder->produce('route_entity')
|
|
|
+ ->map('url', $builder->fromParent())
|
|
|
+ ));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // _____ _ __
|
|
|
+ // |_ _|____ _| |_ _ _ ___ / _|
|
|
|
+ // | |/ -_) \ / _| '_/ -_) _|
|
|
|
+ // |_|\___/_\_\\__|_| \___|_|
|
|
|
+ protected function addTextref(ResolverRegistryInterface $registry, ResolverBuilder $builder) {
|
|
|
+
|
|
|
+ // $language = \Drupal::languageManager()->getCurrentLanguage()->getId();
|
|
|
+
|
|
|
+ $registry->addFieldResolver('Query', 'textref',
|
|
|
+ $builder->produce('entity_load')
|
|
|
+ ->map('type', $builder->fromValue('node'))
|
|
|
+ ->map('bundles', $builder->fromValue(['texte']))
|
|
|
+ ->map('id', $builder->fromArgument('id'))
|
|
|
+ );
|
|
|
+
|
|
|
+ $registry->addFieldResolver('Query', 'textsref',
|
|
|
+ $builder->produce('entity_load_multiple')
|
|
|
+ ->map('type', $builder->fromValue('node'))
|
|
|
+ ->map('ids', $builder->fromArgument('ids'))
|
|
|
+ );
|
|
|
+
|
|
|
+ $registry->addFieldResolver('Textref', 'id',
|
|
|
+ $builder->produce('entity_id')
|
|
|
+ ->map('entity', $builder->fromParent())
|
|
|
+ );
|
|
|
+
|
|
|
+ $registry->addFieldResolver('Textref', 'uuid',
|
|
|
+ $builder->produce('entity_uuid')
|
|
|
+ ->map('entity', $builder->fromParent())
|
|
|
+ );
|
|
|
+
|
|
|
+ $registry->addFieldResolver('Textref', 'path',
|
|
|
+ $builder->compose(
|
|
|
+ $builder->produce('entity_url')
|
|
|
+ ->map('entity', $builder->fromParent()),
|
|
|
+ $builder->produce('url_path')
|
|
|
+ ->map('url', $builder->fromParent())
|
|
|
+ )
|
|
|
+ );
|
|
|
+
|
|
|
+ $registry->addFieldResolver('Textref', 'title',
|
|
|
+ $builder->compose(
|
|
|
+ $builder->produce('entity_label')
|
|
|
+ ->map('entity', $builder->fromParent())
|
|
|
+ ));
|
|
|
+
|
|
|
+ $registry->addFieldResolver('Textref', 'texte',
|
|
|
+ $builder->produce('property_path')
|
|
|
+ ->map('type', $builder->fromValue('entity:node'))
|
|
|
+ ->map('value', $builder->fromParent())
|
|
|
+ ->map('path', $builder->fromValue('body.value'))
|
|
|
+ );
|
|
|
+
|
|
|
+ $registry->addFieldResolver('Textref', 'author',
|
|
|
+ $builder->compose(
|
|
|
+ $builder->produce('entity_owner')
|
|
|
+ ->map('entity', $builder->fromParent()),
|
|
|
+ $builder->produce('entity_label')
|
|
|
+ ->map('entity', $builder->fromParent())
|
|
|
+ ));
|
|
|
+
|
|
|
+ $registry->addFieldResolver('Textref', 'text_en_rebond',
|
|
|
+ $builder->compose(
|
|
|
+ $builder->produce('entity_reference')
|
|
|
+ ->map('entity', $builder->fromParent())
|
|
|
+ ->map('field', $builder->fromValue('field_texte_en_rebond'))
|
|
|
+ ));
|
|
|
+
|
|
|
+ $registry->addFieldResolver('Textref', 'text_produits',
|
|
|
+ $builder->compose(
|
|
|
+ $builder->produce('entity_reference')
|
|
|
+ ->map('entity', $builder->fromParent())
|
|
|
+ ->map('field', $builder->fromValue('field_textes_produits'))
|
|
|
+ ));
|
|
|
+
|
|
|
+ $registry->addFieldResolver('Textref', 'images',
|
|
|
+ $builder->produce('entity_reference')
|
|
|
+ ->map('entity', $builder->fromParent())
|
|
|
+ ->map('field', $builder->fromValue('field_images'))
|
|
|
+ );
|
|
|
+
|
|
|
+ $registry->addFieldResolver('Textref', 'videos',
|
|
|
+ $builder->produce('property_path')
|
|
|
+ ->map('type', $builder->fromValue('entity:node'))
|
|
|
+ ->map('value', $builder->fromParent())
|
|
|
+ ->map('path', $builder->fromValue('field_video'))
|
|
|
+ );
|
|
|
+
|
|
|
+ $registry->addFieldResolver('Textref', 'tags',
|
|
|
+ $builder->produce('entity_reference')
|
|
|
+ ->map('entity', $builder->fromParent())
|
|
|
+ ->map('field', $builder->fromValue('field_tag'))
|
|
|
+ );
|
|
|
+
|
|
|
+ $registry->addFieldResolver('Textref', 'familles',
|
|
|
+ $builder->produce('entity_reference')
|
|
|
+ ->map('entity', $builder->fromParent())
|
|
|
+ ->map('field', $builder->fromValue('field_famille'))
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // _____ _ ___ _
|
|
|
+ // |_ _|____ _| |_| _ \_ _ ___ __| |
|
|
|
+ // | |/ -_) \ / _| _/ '_/ _ \/ _` |
|
|
|
+ // |_|\___/_\_\\__|_| |_| \___/\__,_|
|
|
|
+ protected function addTextprod(ResolverRegistryInterface $registry, ResolverBuilder $builder) {
|
|
|
+
|
|
|
+ // $language = \Drupal::languageManager()->getCurrentLanguage()->getId();
|
|
|
+
|
|
|
+ $registry->addFieldResolver('Query', 'textprod',
|
|
|
+ $builder->produce('entity_load')
|
|
|
+ ->map('type', $builder->fromValue('node'))
|
|
|
+ ->map('bundles', $builder->fromValue(['texte_prod']))
|
|
|
+ ->map('id', $builder->fromArgument('id'))
|
|
|
+ );
|
|
|
+
|
|
|
+ $registry->addFieldResolver('Query', 'textsprod',
|
|
|
+ $builder->produce('entity_load_multiple')
|
|
|
+ ->map('type', $builder->fromValue('node'))
|
|
|
+ ->map('ids', $builder->fromArgument('ids'))
|
|
|
+ );
|
|
|
+
|
|
|
+ $registry->addFieldResolver('Textprod', 'id',
|
|
|
+ $builder->produce('entity_id')
|
|
|
+ ->map('entity', $builder->fromParent())
|
|
|
+ );
|
|
|
+
|
|
|
+ $registry->addFieldResolver('Textprod', 'uuid',
|
|
|
+ $builder->produce('entity_uuid')
|
|
|
+ ->map('entity', $builder->fromParent())
|
|
|
+ );
|
|
|
+
|
|
|
+ $registry->addFieldResolver('Textprod', 'path',
|
|
|
+ $builder->compose(
|
|
|
+ $builder->produce('entity_url')
|
|
|
+ ->map('entity', $builder->fromParent()),
|
|
|
+ $builder->produce('url_path')
|
|
|
+ ->map('url', $builder->fromParent())
|
|
|
+ )
|
|
|
+ );
|
|
|
+
|
|
|
+ $registry->addFieldResolver('Textprod', 'title',
|
|
|
+ $builder->compose(
|
|
|
+ $builder->produce('entity_label')
|
|
|
+ ->map('entity', $builder->fromParent())
|
|
|
+ ));
|
|
|
+
|
|
|
+ $registry->addFieldResolver('Textprod', 'texte',
|
|
|
+ $builder->produce('property_path')
|
|
|
+ ->map('type', $builder->fromValue('entity:node'))
|
|
|
+ ->map('value', $builder->fromParent())
|
|
|
+ ->map('path', $builder->fromValue('body.value'))
|
|
|
+ );
|
|
|
+
|
|
|
+ $registry->addFieldResolver('Textprod', 'author',
|
|
|
+ $builder->compose(
|
|
|
+ $builder->produce('entity_owner')
|
|
|
+ ->map('entity', $builder->fromParent()),
|
|
|
+ $builder->produce('entity_label')
|
|
|
+ ->map('entity', $builder->fromParent())
|
|
|
+ ));
|
|
|
+
|
|
|
+ $registry->addFieldResolver('Textprod', 'text_de_depart',
|
|
|
+ $builder->compose(
|
|
|
+ $builder->produce('entity_reference')
|
|
|
+ ->map('entity', $builder->fromParent())
|
|
|
+ ->map('field', $builder->fromValue('field_texte_de_depart'))
|
|
|
+ ));
|
|
|
+
|
|
|
+ $registry->addFieldResolver('Textprod', 'images',
|
|
|
+ $builder->produce('entity_reference')
|
|
|
+ ->map('entity', $builder->fromParent())
|
|
|
+ ->map('field', $builder->fromValue('field_images'))
|
|
|
+ );
|
|
|
+
|
|
|
+ $registry->addFieldResolver('Textprod', 'videos',
|
|
|
+ $builder->produce('property_path')
|
|
|
+ ->map('type', $builder->fromValue('entity:node'))
|
|
|
+ ->map('value', $builder->fromParent())
|
|
|
+ ->map('path', $builder->fromValue('field_video'))
|
|
|
+ );
|
|
|
+
|
|
|
+ $registry->addFieldResolver('Textprod', 'tags',
|
|
|
+ $builder->produce('entity_reference')
|
|
|
+ ->map('entity', $builder->fromParent())
|
|
|
+ ->map('field', $builder->fromValue('field_tag_prod'))
|
|
|
+ );
|
|
|
+
|
|
|
+ $registry->addFieldResolver('Textprod', 'familles',
|
|
|
+ $builder->produce('entity_reference')
|
|
|
+ ->map('entity', $builder->fromParent())
|
|
|
+ ->map('field', $builder->fromValue('field_famille'))
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ // ___ _
|
|
|
+ // | \ __ _| |_ ___
|
|
|
+ // | |) / _` | _/ -_)
|
|
|
+ // |___/\__,_|\__\___|
|
|
|
+ protected function addDate(ResolverRegistryInterface $registry, ResolverBuilder $builder) {
|
|
|
+ $registry->addFieldResolver('Date', 'start',
|
|
|
+ $builder->callback(function ($parent, $args) {
|
|
|
+ return isset($parent[0]) ? $parent[0]['value'] : null;
|
|
|
+ })
|
|
|
+ );
|
|
|
+ $registry->addFieldResolver('Date', 'end',
|
|
|
+ $builder->callback(function ($parent, $args) {
|
|
|
+ return isset($parent[0]) ? $parent[0]['end_value'] : null;
|
|
|
+ })
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ // ___ _ _ __ _ _ _
|
|
|
+ // | __(_) |___ / _(_)___| |__| |
|
|
|
+ // | _|| | / -_) _| / -_) / _` |
|
|
|
+ // |_| |_|_\___|_| |_\___|_\__,_|
|
|
|
+ protected function addFilefield(ResolverRegistryInterface $registry, ResolverBuilder $builder) {
|
|
|
+ $registry->addFieldResolver('Filefield', 'description',
|
|
|
+ $builder->callback(function ($parent, $args) {
|
|
|
+ return $parent['description'];
|
|
|
+ })
|
|
|
+ );
|
|
|
+ $registry->addFieldResolver('Filefield', 'file',
|
|
|
+ $builder->callback(function ($parent, $args) {
|
|
|
+ return \Drupal\file\Entity\File::load($parent['target_id']);
|
|
|
+ })
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ // ___ _ _
|
|
|
+ // | __(_) |___
|
|
|
+ // | _|| | / -_)
|
|
|
+ // |_| |_|_\___|
|
|
|
+ protected function addFile(ResolverRegistryInterface $registry, ResolverBuilder $builder) {
|
|
|
+ $registry->addFieldResolver('File', 'url',
|
|
|
+ $builder->callback(function ($parent, $args) {
|
|
|
+ return $parent->url();
|
|
|
+ })
|
|
|
+ );
|
|
|
+
|
|
|
+ $registry->addFieldResolver('File', 'filesize',
|
|
|
+ $builder->callback(function ($parent, $args) {
|
|
|
+ return $parent->getSize();
|
|
|
+ })
|
|
|
+ );
|
|
|
+
|
|
|
+ $registry->addFieldResolver('File', 'filemime',
|
|
|
+ $builder->callback(function ($parent, $args) {
|
|
|
+ return $parent->getMimeType();
|
|
|
+ })
|
|
|
+ );
|
|
|
+
|
|
|
+ $registry->addFieldResolver('File', 'filename',
|
|
|
+ $builder->callback(function ($parent, $args) {
|
|
|
+ return $parent->getFilename();
|
|
|
+ })
|
|
|
+ );
|
|
|
+
|
|
|
+ $registry->addFieldResolver('File', 'fid',
|
|
|
+ $builder->callback(function ($parent, $args) {
|
|
|
+ return $parent->id();
|
|
|
+ })
|
|
|
+ );
|
|
|
+
|
|
|
+ $registry->addFieldResolver('File', 'uuid',
|
|
|
+ $builder->callback(function ($parent, $args) {
|
|
|
+ return $parent->uuid();
|
|
|
+ })
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ // ___
|
|
|
+ // |_ _|_ __ __ _ __ _ ___
|
|
|
+ // | || ' \/ _` / _` / -_)
|
|
|
+ // |___|_|_|_\__,_\__, \___|
|
|
|
+ // |___/
|
|
|
+ protected function addImage(ResolverRegistryInterface $registry, ResolverBuilder $builder) {
|
|
|
+ $registry->addFieldResolver('Image', 'id',
|
|
|
+ $builder->produce('entity_id')
|
|
|
+ ->map('entity', $builder->fromParent())
|
|
|
+ );
|
|
|
+
|
|
|
+ $registry->addFieldResolver('Image', 'url',
|
|
|
+ $builder->produce('image_url')
|
|
|
+ ->map('entity', $builder->fromParent())
|
|
|
+ );
|
|
|
+
|
|
|
+ $registry->addFieldResolver('Image', 'alt',
|
|
|
+ $builder->produce('property_path')
|
|
|
+ ->map('type', $builder->fromValue('entity:node'))
|
|
|
+ ->map('value', $builder->fromParent())
|
|
|
+ ->map('path', $builder->fromValue('field_image.alt'))
|
|
|
+ );
|
|
|
+
|
|
|
+ $registry->addFieldResolver('Image', 'style_minicard',
|
|
|
+ $builder->produce('image_derivative')
|
|
|
+ ->map('entity', $builder->fromParent())
|
|
|
+ ->map('style', $builder->fromValue('card_medium_half'))
|
|
|
+ );
|
|
|
+
|
|
|
+ $registry->addFieldResolver('Image', 'style_minicard_url',
|
|
|
+ $builder->compose(
|
|
|
+ $builder->produce('image_derivative')
|
|
|
+ ->map('entity', $builder->fromParent())
|
|
|
+ ->map('style', $builder->fromValue('card_medium_half')),
|
|
|
+ $builder->callback(function($parent, $args){
|
|
|
+ return $parent['url'];
|
|
|
+ })
|
|
|
+ ));
|
|
|
+
|
|
|
+ $registry->addFieldResolver('Image', 'style_linkedmaterialcard',
|
|
|
+ $builder->produce('image_derivative')
|
|
|
+ ->map('entity', $builder->fromParent())
|
|
|
+ ->map('style', $builder->fromValue('linkedmaterial_card'))
|
|
|
+ );
|
|
|
+
|
|
|
+ $registry->addFieldResolver('Image', 'style_linkedmaterialcard_url',
|
|
|
+ $builder->compose(
|
|
|
+ $builder->produce('image_derivative')
|
|
|
+ ->map('entity', $builder->fromParent())
|
|
|
+ ->map('style', $builder->fromValue('linkedmaterial_card')),
|
|
|
+ $builder->callback(function($parent, $args){
|
|
|
+ return $parent['url'];
|
|
|
+ })
|
|
|
+ ));
|
|
|
+
|
|
|
+ $registry->addFieldResolver('Image', 'style_cardmedium',
|
|
|
+ $builder->produce('image_derivative')
|
|
|
+ ->map('entity', $builder->fromParent())
|
|
|
+ ->map('style', $builder->fromValue('card_medium'))
|
|
|
+ );
|
|
|
+
|
|
|
+ $registry->addFieldResolver('Image', 'style_cardmedium_url',
|
|
|
+ $builder->compose(
|
|
|
+ $builder->produce('image_derivative')
|
|
|
+ ->map('entity', $builder->fromParent())
|
|
|
+ ->map('style', $builder->fromValue('card_medium')),
|
|
|
+ $builder->callback(function($parent, $args){
|
|
|
+ return $parent['url'];
|
|
|
+ })
|
|
|
+ ));
|
|
|
+
|
|
|
+ $registry->addFieldResolver('Image', 'style_cardfull',
|
|
|
+ $builder->produce('image_derivative')
|
|
|
+ ->map('entity', $builder->fromParent())
|
|
|
+ ->map('style', $builder->fromValue('card_full'))
|
|
|
+ );
|
|
|
+
|
|
|
+ $registry->addFieldResolver('Image', 'style_cardfull_url',
|
|
|
+ $builder->compose(
|
|
|
+ $builder->produce('image_derivative')
|
|
|
+ ->map('entity', $builder->fromParent())
|
|
|
+ ->map('style', $builder->fromValue('card_full')),
|
|
|
+ $builder->callback(function($parent, $args){
|
|
|
+ return $parent['url'];
|
|
|
+ })
|
|
|
+ ));
|
|
|
+
|
|
|
+ $registry->addFieldResolver('Image', 'style_articlecardmedium',
|
|
|
+ $builder->produce('image_derivative')
|
|
|
+ ->map('entity', $builder->fromParent())
|
|
|
+ ->map('style', $builder->fromValue('article_card_medium'))
|
|
|
+ );
|
|
|
+
|
|
|
+ $registry->addFieldResolver('Image', 'style_articlecardmedium_url',
|
|
|
+ $builder->compose(
|
|
|
+ $builder->produce('image_derivative')
|
|
|
+ ->map('entity', $builder->fromParent())
|
|
|
+ ->map('style', $builder->fromValue('article_card_medium')),
|
|
|
+ $builder->callback(function($parent, $args){
|
|
|
+ return $parent['url'];
|
|
|
+ })
|
|
|
+ ));
|
|
|
+
|
|
|
+ $registry->addFieldResolver('Image', 'style_hd',
|
|
|
+ $builder->produce('image_derivative')
|
|
|
+ ->map('entity', $builder->fromParent())
|
|
|
+ ->map('style', $builder->fromValue('hd'))
|
|
|
+ );
|
|
|
+
|
|
|
+ $registry->addFieldResolver('Image', 'style_hd_url',
|
|
|
+ $builder->compose(
|
|
|
+ $builder->produce('image_derivative')
|
|
|
+ ->map('entity', $builder->fromParent())
|
|
|
+ ->map('style', $builder->fromValue('hd')),
|
|
|
+ $builder->callback(function($parent, $args){
|
|
|
+ return $parent['url'];
|
|
|
+ })
|
|
|
+ ));
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ // __ ___ _ _ _ _
|
|
|
+ // \ \ / (_)__| |___ ___| | (_)_ _ | |__
|
|
|
+ // \ V /| / _` / -_) _ \ |__| | ' \| / /
|
|
|
+ // \_/ |_\__,_\___\___/____|_|_||_|_\_\
|
|
|
+ protected function addVideolink(ResolverRegistryInterface $registry, ResolverBuilder $builder) {
|
|
|
+ $registry->addFieldResolver('VideoLink', 'url',
|
|
|
+ $builder->produce('property_path')
|
|
|
+ ->map('type', $builder->fromValue('field_item:video_embed_field'))
|
|
|
+ ->map('value', $builder->fromParent())
|
|
|
+ ->map('path', $builder->fromValue('value'))
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ // _____
|
|
|
+ // |_ _|_ _ __ _
|
|
|
+ // | |/ _` / _` |
|
|
|
+ // |_|\__,_\__, |
|
|
|
+ // |___/
|
|
|
+ protected function addTaxoterm(ResolverRegistryInterface $registry, ResolverBuilder $builder) {
|
|
|
+ $registry->addFieldResolver('Query', 'tag',
|
|
|
+ $builder->produce('entity_load')
|
|
|
+ ->map('type', $builder->fromValue('taxonomy_term'))
|
|
|
+ ->map('bundles', $builder->fromValue(['tag']))
|
|
|
+ ->map('id', $builder->fromArgument('id'))
|
|
|
+ );
|
|
|
+ $registry->addFieldResolver('Query', 'famille',
|
|
|
+ $builder->produce('entity_load')
|
|
|
+ ->map('type', $builder->fromValue('taxonomy_term'))
|
|
|
+ ->map('bundles', $builder->fromValue(['famille']))
|
|
|
+ ->map('id', $builder->fromArgument('id'))
|
|
|
+ );
|
|
|
+ $registry->addFieldResolver('Query', 'tagprod',
|
|
|
+ $builder->produce('entity_load')
|
|
|
+ ->map('type', $builder->fromValue('taxonomy_term'))
|
|
|
+ ->map('bundles', $builder->fromValue(['tag_prod']))
|
|
|
+ ->map('id', $builder->fromArgument('id'))
|
|
|
+ );
|
|
|
+
|
|
|
+ $registry->addFieldResolver('Taxoterm', 'id',
|
|
|
+ $builder->produce('entity_id')
|
|
|
+ ->map('entity', $builder->fromParent())
|
|
|
+ );
|
|
|
+
|
|
|
+ $registry->addFieldResolver('Taxoterm', 'uuid',
|
|
|
+ $builder->produce('entity_uuid')
|
|
|
+ ->map('entity', $builder->fromParent())
|
|
|
+ );
|
|
|
+
|
|
|
+ $registry->addFieldResolver('Taxoterm', 'name',
|
|
|
+ $builder->produce('entity_label')
|
|
|
+ ->map('entity', $builder->fromParent())
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|