public function FieldTemplateProcessor::process in UI Patterns 8
Process field template variables.
Parameters
array $variables: Variables array.
Overrides FieldTemplateProcessorInterface::process
See also
template_preprocess_field__pattern_ds_field_template()
File
- modules/
ui_patterns_ds/ src/ FieldTemplateProcessor.php, line 24
Class
- FieldTemplateProcessor
- Class FieldTemplateProcessor.
Namespace
Drupal\ui_patterns_dsCode
public function process(array &$variables) {
$this->variables = $variables;
$content = [];
foreach ($variables['items'] as $delta => $item) {
$fields = [];
foreach ($this
->getMapping() as $mapping) {
$fields[$mapping['destination']][] = $this
->getSourceValue($mapping, $delta);
}
$content['pattern_' . $delta] = [
'#type' => 'pattern',
'#id' => $this
->getPatternId(),
'#variant' => $this
->getVariant(),
'#fields' => $fields,
'#context' => $this
->getContext(),
'#multiple_sources' => TRUE,
];
}
$variables['pattern'] = $content;
}