public function ViewEmbed::buildSettingsForm in Dashboards with Layout Builder 8
Same name and namespace in other branches
- 2.0.x src/Plugin/Dashboard/ViewEmbed.php \Drupal\dashboards\Plugin\Dashboard\ViewEmbed::buildSettingsForm()
Build render array.
Parameters
array $form: Default form.
\Drupal\Core\Form\FormStateInterface $form_state: Default form.
array $configuration: Configuration.
Return value
array Return form array.
Overrides DashboardBase::buildSettingsForm
File
- src/
Plugin/ Dashboard/ ViewEmbed.php, line 79
Class
- ViewEmbed
- Show account info.
Namespace
Drupal\dashboards\Plugin\DashboardCode
public function buildSettingsForm(array $form, FormStateInterface $form_state, array $configuration) : array {
$views = $this->entityQuery
->condition('status', TRUE)
->condition("display.*.display_plugin", [
'embed',
], 'IN')
->execute();
$views = View::loadMultiple($views);
$options = [];
foreach ($views as $view) {
foreach ($view
->get('display') as $display) {
if ($display['display_plugin'] != 'embed') {
continue;
}
$options[$view
->id() . ':' . $display['id']] = $view
->label() . ': ' . $display['display_title'];
}
}
if (empty($options)) {
$form['view'] = [
'#markup' => $this
->t('Please add a embed view to use this plugin.'),
];
return $form;
}
$form['view'] = [
'#type' => 'select',
'#required' => TRUE,
'#options' => $options,
'#default_value' => isset($configuration['view']) ? $configuration['view'] : FALSE,
];
return $form;
}