Reduced single-property fields to scalars.#385
Conversation
| $type = $definition['type']; | ||
| $result = $item->$property; | ||
|
|
||
| if ($type == 'Int') { |
There was a problem hiding this comment.
You can make this a strict comparison.
| if ($type == 'Int') { | ||
| $result = (int) $result; | ||
| } | ||
| elseif ($type == 'Float') { |
| $properties = $item->getProperties(TRUE); | ||
| if (count($properties) == 1) { | ||
| yield $this->resolveItem($item); | ||
| }else { |
There was a problem hiding this comment.
We write else on a new line in Drupal.
| foreach ($value->get($fieldName) as $item) { | ||
| yield $item; | ||
| $properties = $item->getProperties(TRUE); | ||
| if (count($properties) == 1) { |
There was a problem hiding this comment.
This should be a strict comparison
|
|
||
| $derivative['type'] = $this->typeMapper->typedDataToGraphQLFieldType($property); | ||
| $derivative['property'] = reset($keys); | ||
| }else { |
There was a problem hiding this comment.
We write else on a new line.
| $derivative['type'] = EntityFieldType::getId($entityTypeId, $fieldName); | ||
| } | ||
|
|
||
| if ($bundleId) { |
There was a problem hiding this comment.
Always check empty / !empty instead of just checking the truthy value of a parameter.
| ]; | ||
|
|
||
| $properties = $definition->getPropertyDefinitions(); | ||
| if (count($properties) == 1) { |
There was a problem hiding this comment.
This should be a strict comparison ===.
|
All the comments addressed. |
| $definition = $this->getPluginDefinition(); | ||
| $property = $definition['property']; | ||
| $type = $definition['type']; | ||
| $result = $item->$property; |
There was a problem hiding this comment.
I'd prefer an explicit $item->get($property) here.
| $derivative['type'] = EntityFieldType::getId($entityTypeId, $fieldName); | ||
| } | ||
|
|
||
| if (is_null($bundleId)) { |
There was a problem hiding this comment.
This whole condition block could be written in-line.
| * @param null|string $bundleId | ||
| * Bundle id. | ||
| */ | ||
| protected abstract function getDerivativesFromPropertyDefinitions($entityTypeId, FieldStorageDefinitionInterface $definition, array $basePluginDefinition, $bundleId = NULL); |
There was a problem hiding this comment.
abstract protected function, not protected abstract function.
|
I'm sorry to step in so late. We had the idea to attach features of current display-driven fields to raw value types (e.g. the Are we able to check if there is a plugin that binds to this type first before simplifying it? |
Issue: #377