mapper = $mapper; $this->typeLocator = $typeLocator; $this->collection = $collection; $this->config = $config; } /** * Read configuration scope * * @param string|null $scope * @return array * @throws GraphQlInputException * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function read($scope = null) : array { $config = []; if ($this->config->isSetFlag(self::XML_PATH_INCLUDE_DYNAMIC_ATTRIBUTES, ScopeInterface::SCOPE_STORE)) { $typeNames = $this->mapper->getMappedTypes(Product::ENTITY); /** @var Attribute $attribute */ foreach ($this->collection->getAttributes() as $attribute) { $attributeCode = $attribute->getAttributeCode(); $locatedType = $this->typeLocator->getType($attributeCode, Product::ENTITY) ?: 'String'; $locatedType = TypeProcessor::NORMALIZED_ANY_TYPE === $locatedType ? 'String' : ucfirst($locatedType); foreach ($typeNames as $typeName) { $config[$typeName]['fields'][$attributeCode] = [ 'name' => $attributeCode, 'type' => $locatedType, 'arguments' => [], 'deprecated' => ['reason' => 'Use the `custom_attributes` field instead.'], ]; } } } return $config; } }