|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Drupal\graphql_core\Plugin\Deriver\Fields; |
|
4
|
|
|
|
|
5
|
|
|
use Drupal\Core\Field\FieldDefinitionInterface; |
|
|
|
|
|
|
6
|
|
|
use Drupal\Core\TypedData\ComplexDataDefinitionInterface; |
|
|
|
|
|
|
7
|
|
|
use Drupal\Core\TypedData\ListDataDefinitionInterface; |
|
|
|
|
|
|
8
|
|
|
use Drupal\graphql\Utility\StringHelper; |
|
9
|
|
|
use Drupal\graphql_core\Plugin\Deriver\EntityFieldDeriverBase; |
|
10
|
|
|
|
|
11
|
|
|
class EntityFieldDeriver extends EntityFieldDeriverBase { |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* {@inheritdoc} |
|
15
|
|
|
*/ |
|
16
|
|
|
protected function getDerivativeDefinitionsFromFieldDefinition(FieldDefinitionInterface $fieldDefinition, array $basePluginDefinition) { |
|
17
|
|
|
$itemDefinition = $fieldDefinition->getItemDefinition(); |
|
18
|
|
|
if (!($itemDefinition instanceof ComplexDataDefinitionInterface) || !$propertyDefinitions = $itemDefinition->getPropertyDefinitions()) { |
|
19
|
|
|
return []; |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
|
|
$tags = array_merge($fieldDefinition->getCacheTags(), ['entity_field_info']); |
|
23
|
|
|
$maxAge = $fieldDefinition->getCacheMaxAge(); |
|
24
|
|
|
$contexts = $fieldDefinition->getCacheContexts(); |
|
25
|
|
|
|
|
26
|
|
|
$entityTypeId = $fieldDefinition->getTargetEntityTypeId(); |
|
27
|
|
|
$entityType = $this->entityTypeManager->getDefinition($entityTypeId); |
|
28
|
|
|
$supportsBundles = $entityType->hasKey('bundle'); |
|
29
|
|
|
$fieldName = $fieldDefinition->getName(); |
|
30
|
|
|
$fieldBundle = $fieldDefinition->getTargetBundle() ?: ''; |
|
31
|
|
|
|
|
32
|
|
|
$derivative = [ |
|
33
|
|
|
'parents' => [StringHelper::camelCase($entityTypeId, $supportsBundles ? $fieldBundle : '')], |
|
34
|
|
|
'name' => StringHelper::propCase($fieldName), |
|
35
|
|
|
'description' => $fieldDefinition->getDescription(), |
|
36
|
|
|
'field' => $fieldName, |
|
37
|
|
|
'schema_cache_tags' => $tags, |
|
38
|
|
|
'schema_cache_contexts' => $contexts, |
|
39
|
|
|
'schema_cache_max_age' => $maxAge, |
|
40
|
|
|
] + $basePluginDefinition; |
|
41
|
|
|
|
|
42
|
|
|
if (count($propertyDefinitions) === 1) { |
|
43
|
|
|
$propertyDefinition = reset($propertyDefinitions); |
|
44
|
|
|
$derivative['type'] = $propertyDefinition->getDataType(); |
|
45
|
|
|
$derivative['property'] = key($propertyDefinitions); |
|
46
|
|
|
} |
|
47
|
|
|
else { |
|
48
|
|
|
$derivative['type'] = StringHelper::camelCase('field', $entityTypeId, $supportsBundles ? $fieldBundle : '', $fieldName); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
// Fields are usually multi-value. Simplify them for the schema if they are |
|
52
|
|
|
// configured for cardinality 1 (only works for configured fields). |
|
53
|
|
|
if (!(($storageDefinition = $fieldDefinition->getFieldStorageDefinition()) && !$storageDefinition->isMultiple())) { |
|
54
|
|
|
$derivative['type'] = StringHelper::listType($derivative['type']); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
return ["$entityTypeId-$fieldName-$fieldBundle" => $derivative]; |
|
58
|
|
|
} |
|
59
|
|
|
} |
|
60
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths