TypedData instances created by TypedConfigManager::createFromNameAndData() are incomplete

Created on 17 May 2023, about 2 years ago
Updated 25 May 2023, about 2 years ago

Problem/Motivation

#2869809: Make it easy to get typed config representations of entities โ†’ introduced \Drupal\Core\Config\TypedConfigManager::createFromNameAndData():

  public function createFromNameAndData($config_name, array $config_data) {
    $definition = $this->getDefinition($config_name);
    $data_definition = $this->buildDataDefinition($definition, $config_data);
    return $this->create($data_definition, $config_data);
  }

It's great! It's used in many places.

But it has one bug: the \Drupal\Core\TypedData\TraversableTypedDataInterface instances it returns do not have a working getName() nor a working getPropertyPath(), because we forgot to pass the third argument to ::create(): public function create(DataDefinitionInterface $definition, $value = NULL, $name = NULL, $parent = NULL) { โ€” the $name!

Steps to reproduce

N/A โ€” discovered in โœจ Expose validation constraints (and validatability %) in Config Inspector UI Fixed .

Proposed resolution

Specify $name.

Remaining tasks

None.

User interface changes

None.

API changes

None.

Data model changes

None.

Release notes snippet

N/A

๐Ÿ› Bug report
Status

Fixed

Version

10.1 โœจ

Component
Configurationย  โ†’

Last updated about 13 hours ago

Created by

๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024