protected function MappingForm::buildLegend in Feeds 8.3
Builds legend which explains source and target elements.
Parameters
array $form: The complete mapping form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the complete form.
Return value
array The legend form element.
1 call to MappingForm::buildLegend()
- MappingForm::buildForm in src/
Form/ MappingForm.php - Form constructor.
File
- src/
Form/ MappingForm.php, line 454
Class
- MappingForm
- Provides a form for mapping settings.
Namespace
Drupal\feeds\FormCode
protected function buildLegend(array $form, FormStateInterface $form_state) {
$element = [
'#type' => 'details',
'#title' => $this
->t('Legend'),
'sources' => [
'#caption' => $this
->t('Sources'),
'#type' => 'table',
'#header' => [
$this
->t('Name'),
$this
->t('Machine name'),
$this
->t('Description'),
],
'#rows' => [],
],
'targets' => [
'#caption' => $this
->t('Targets'),
'#type' => 'table',
'#header' => [
$this
->t('Name'),
$this
->t('Machine name'),
$this
->t('Description'),
],
'#rows' => [],
],
];
foreach ($this->feedType
->getMappingSources() as $key => $info) {
$element['sources']['#rows'][$key] = [
'label' => $info['label'],
'name' => $key,
'description' => isset($info['description']) ? $info['description'] : NULL,
];
}
asort($element['sources']['#rows']);
/** @var \Drupal\feeds\TargetDefinitionInterface $definition */
foreach ($this->targets as $key => $definition) {
$element['targets']['#rows'][$key] = [
'label' => $definition
->getLabel(),
'name' => $key,
'description' => $definition
->getDescription(),
];
}
return $element;
}