|
@@ -26,6 +26,8 @@ class MaterioSchemaExtension extends SdlSchemaExtensionPluginBase {
|
|
|
|
|
|
$this->addMateriau($registry, $builder);
|
|
|
|
|
|
+ $this->addSample($registry, $builder);
|
|
|
+
|
|
|
$this->addArticle($registry, $builder);
|
|
|
|
|
|
$this->addCompany($registry, $builder);
|
|
@@ -175,14 +177,55 @@ class MaterioSchemaExtension extends SdlSchemaExtensionPluginBase {
|
|
|
->map('field', $builder->fromValue('field_distributor'))
|
|
|
);
|
|
|
|
|
|
- // field_famille
|
|
|
- // field_index
|
|
|
- // field_reference
|
|
|
- // field_samples
|
|
|
+ // $registry->addFieldResolver('Materiau', 'famille',
|
|
|
+ // $builder->produce('property_path')
|
|
|
+ // ->map('type', $builder->fromValue('entity:node'))
|
|
|
+ // ->map('value', $builder->fromParent())
|
|
|
+ // ->map('path', $builder->fromValue('field_famille.value'))
|
|
|
+ // );
|
|
|
+ //
|
|
|
+ // $registry->addFieldResolver('Materiau', 'index',
|
|
|
+ // $builder->produce('property_path')
|
|
|
+ // ->map('type', $builder->fromValue('entity:node'))
|
|
|
+ // ->map('value', $builder->fromParent())
|
|
|
+ // ->map('path', $builder->fromValue('field_index.value'))
|
|
|
+ // );
|
|
|
+
|
|
|
+ $registry->addFieldResolver('Materiau', 'reference',
|
|
|
+ $builder->produce('property_path')
|
|
|
+ ->map('type', $builder->fromValue('entity:node'))
|
|
|
+ ->map('value', $builder->fromParent())
|
|
|
+ ->map('path', $builder->fromValue('field_reference.value'))
|
|
|
+ );
|
|
|
+
|
|
|
+ $registry->addFieldResolver('Materiau', 'samples',
|
|
|
+ $builder->produce('property_path')
|
|
|
+ ->map('type', $builder->fromValue('entity:node'))
|
|
|
+ ->map('value', $builder->fromParent())
|
|
|
+ ->map('path', $builder->fromValue('field_samples'))
|
|
|
+ );
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
+ // ___ _
|
|
|
+ // / __| __ _ _ __ _ __| |___
|
|
|
+ // \__ \/ _` | ' \| '_ \ / -_)
|
|
|
+ // |___/\__,_|_|_|_| .__/_\___|
|
|
|
+ // |_|
|
|
|
+ protected function addSample(ResolverRegistryInterface $registry, ResolverBuilder $builder) {
|
|
|
+ $registry->addFieldResolver('Sample', 'showroom',
|
|
|
+ $builder->callback(function($parent, $args){
|
|
|
+ return \Drupal\taxonomy\Entity\Term::load($parent['target_id']);
|
|
|
+ })
|
|
|
+ );
|
|
|
+ $registry->addFieldResolver('Sample', 'location',
|
|
|
+ $builder->callback(function($parent, $args){
|
|
|
+ return $parent['location'];
|
|
|
+ })
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
// _ _ _ _
|
|
|
// /_\ _ _| |_(_)__| |___
|
|
|
// / _ \| '_| _| / _| / -_)
|
|
@@ -435,6 +478,28 @@ class MaterioSchemaExtension extends SdlSchemaExtensionPluginBase {
|
|
|
$builder->produce('entity_label')
|
|
|
->map('entity', $builder->fromParent())
|
|
|
);
|
|
|
+
|
|
|
+ $registry->addFieldResolver('Showroom', 'email',
|
|
|
+ $builder->produce('property_path')
|
|
|
+ ->map('type', $builder->fromValue('entity:taxonomy_term'))
|
|
|
+ ->map('value', $builder->fromParent())
|
|
|
+ ->map('path', $builder->fromValue('field_public_email.value'))
|
|
|
+ );
|
|
|
+
|
|
|
+ $registry->addFieldResolver('Showroom', 'address',
|
|
|
+ $builder->produce('property_path')
|
|
|
+ ->map('type', $builder->fromValue('entity:taxonomy_term'))
|
|
|
+ ->map('value', $builder->fromParent())
|
|
|
+ ->map('path', $builder->fromValue('field_public_address'))
|
|
|
+ );
|
|
|
+
|
|
|
+ $registry->addFieldResolver('Showroom', 'phone',
|
|
|
+ $builder->produce('property_path')
|
|
|
+ ->map('type', $builder->fromValue('entity:taxonomy_term'))
|
|
|
+ ->map('value', $builder->fromParent())
|
|
|
+ ->map('path', $builder->fromValue('field_public_phone.value'))
|
|
|
+ );
|
|
|
+
|
|
|
}
|
|
|
|
|
|
// _ _ _
|
|
@@ -626,7 +691,6 @@ class MaterioSchemaExtension extends SdlSchemaExtensionPluginBase {
|
|
|
);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
// ___
|
|
|
// / __|___ _ __ _ __ __ _ _ _ _ _
|
|
|
// | (__/ _ \ ' \| '_ \/ _` | ' \ || |
|
|
@@ -641,19 +705,25 @@ class MaterioSchemaExtension extends SdlSchemaExtensionPluginBase {
|
|
|
);
|
|
|
|
|
|
$registry->addFieldResolver('Company', 'id',
|
|
|
- $builder->produce('entity_id')
|
|
|
- ->map('entity', $builder->fromParent())
|
|
|
- );
|
|
|
+ $builder->produce('entity_id')
|
|
|
+ ->map('entity', $builder->fromParent())
|
|
|
+ );
|
|
|
|
|
|
$registry->addFieldResolver('Company', 'uuid',
|
|
|
- $builder->produce('entity_uuid')
|
|
|
- ->map('entity', $builder->fromParent())
|
|
|
- );
|
|
|
+ $builder->produce('entity_uuid')
|
|
|
+ ->map('entity', $builder->fromParent())
|
|
|
+ );
|
|
|
|
|
|
$registry->addFieldResolver('Company', 'name',
|
|
|
- $builder->produce('entity_label')
|
|
|
- ->map('entity', $builder->fromParent())
|
|
|
- );
|
|
|
+ $builder->produce('entity_label')
|
|
|
+ ->map('entity', $builder->fromParent())
|
|
|
+ );
|
|
|
+
|
|
|
+ $registry->addFieldResolver('Company', 'description',
|
|
|
+ $builder->callback(function($parent, $args){
|
|
|
+ return $parent->getDescription();
|
|
|
+ })
|
|
|
+ );
|
|
|
|
|
|
// TODO: property_path helper
|
|
|
// $props = [
|
|
@@ -721,8 +791,19 @@ class MaterioSchemaExtension extends SdlSchemaExtensionPluginBase {
|
|
|
->map('path', $builder->fromValue('field_public_address'))
|
|
|
);
|
|
|
|
|
|
- // field_infos_from_company
|
|
|
- // field_public_phone
|
|
|
+ $registry->addFieldResolver('Company', 'phone',
|
|
|
+ $builder->produce('property_path')
|
|
|
+ ->map('type', $builder->fromValue('entity:taxonomy_term'))
|
|
|
+ ->map('value', $builder->fromParent())
|
|
|
+ ->map('path', $builder->fromValue('field_public_phone.value'))
|
|
|
+ );
|
|
|
+
|
|
|
+ $registry->addFieldResolver('Company', 'infos',
|
|
|
+ $builder->produce('property_path')
|
|
|
+ ->map('type', $builder->fromValue('entity:taxonomy_term'))
|
|
|
+ ->map('value', $builder->fromParent())
|
|
|
+ ->map('path', $builder->fromValue('field_infos_from_company.value'))
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
/**
|