- Issue created by @joachim
The TypeResolver recurses up schema addresses that can contain wildcards %parent and %key.
It starts off by setting these up with the initial data:
$data = [
'%parent' => $data->getParent(),
'%key' => $data->getName(),
'%type' => $data->getDataDefinition()->getDataType(),
];
Here, %key is set to be the name of the initial data.
At the end of the iteration, if an address part is %parent, the wildcard values need to be updated to go up the tree:
// Switch replacement values with values from the parent.
$parent = $data['%parent'];
$data = $parent->getValue();
$data['%type'] = $parent->getDataDefinition()->getDataType();
// The special %parent and %key values now need to point one level up.
if ($new_parent = $parent->getParent()) {
$data['%parent'] = $new_parent;
$data['%key'] = $new_parent->getName();
}
Walking through this:
> $parent = $data['%parent'];
That's the parent of the first iteration.
> $data = $parent->getValue();
We've now updated $data to be for iteration 2.
> if ($new_parent = $parent->getParent()) {
We get a new parent -- the iteration 2 parent, or the grandparent of the initial data.
> $data['%parent'] = $new_parent;
Our new parent for iteration 2 is this parent.
> $data['%key'] = $new_parent->getName();
The key is here set to the name of the NEW parent -- the grandparent.
At the start of the process, it was set to the name of the initial data.
There is never a point where %key is the name of the initial parent.
Given this schema:
channels:
type: sequence
label: Finder channels
sequence:
type: sequence
label: Finder channel bundles
sequence:
type: text
label: Bundle name
constraints:
EntityBundleExists: '...'
and this config value:
channels:
node:
- my_bundle
There does not seem to be a way to pass 'node' to the EntityBundleExists constraint, because %key is first 0, then 'channels', but never 'node'.
Active
11.0 🔥
configuration system