public function FreelinkingPrepopulate::settingsForm in Freelinking 4.0.x
Same name and namespace in other branches
- 8.3 modules/freelinking_prepopulate/src/Plugin/freelinking/FreelinkingPrepopulate.php \Drupal\freelinking_prepopulate\Plugin\freelinking\FreelinkingPrepopulate::settingsForm()
Plugin configuration form.
Parameters
array $form: The form element array for the filter plugin.
\Drupal\Core\Form\FormStateInterface $form_state: The form state of the parent form.
Return value
array The configuration form to attach to Freelinking settings form.
Overrides FreelinkingPluginBase::settingsForm
File
- modules/
freelinking_prepopulate/ src/ Plugin/ freelinking/ FreelinkingPrepopulate.php, line 129
Class
- FreelinkingPrepopulate
- Freelinking prepopulate plugin.
Namespace
Drupal\freelinking_prepopulate\Plugin\freelinkingCode
public function settingsForm(array $form, FormStateInterface $form_state) {
$element = [];
$config = $this
->getConfiguration();
$element['failover'] = [
'#type' => 'select',
'#title' => $this
->t('If path alias is not found'),
'#description' => $this
->t('What should freelinking do when the page is not found?'),
'#options' => [
'error' => $this
->t('Insert an error message'),
],
'#default_value' => $config['settings']['failover'],
];
if ($this->moduleHandler
->moduleExists('search')) {
$element['failover']['#options']['search'] = $this
->t('Add link to search content');
}
$node_types = $this->entityTypeManager
->getStorage('node_type')
->loadMultiple();
$options = array_reduce($node_types, function (&$result, $node_type) {
/** @var \Drupal\node\Entity\NodeType $node_type */
$result[$node_type
->id()] = $node_type
->label();
return $result;
}, []);
$element['default_node_type'] = [
'#type' => 'select',
'#title' => $this
->t('Content type'),
'#description' => $this
->t('Choose the default node type to use for Node Create links.'),
'#options' => $options,
'#required' => TRUE,
'#default_value' => $config['settings']['default_node_type'],
];
// @todo Add advanced field options.
return $element;
}