public function AddForm::submitForm in Linkit 8.4
Same name in this branch
- 8.4 src/Form/Attribute/AddForm.php \Drupal\linkit\Form\Attribute\AddForm::submitForm()
- 8.4 src/Form/Matcher/AddForm.php \Drupal\linkit\Form\Matcher\AddForm::submitForm()
Same name and namespace in other branches
- 8.5 src/Form/Matcher/AddForm.php \Drupal\linkit\Form\Matcher\AddForm::submitForm()
Form submission handler.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Overrides FormInterface::submitForm
File
- src/
Form/ Matcher/ AddForm.php, line 111 - Contains \Drupal\linkit\Form\Matcher\AddForm.
Class
- AddForm
- Provides a form to apply matchers to a profile.
Namespace
Drupal\linkit\Form\MatcherCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$form_state
->cleanValues();
/** @var \Drupal\linkit\MatcherInterface $plugin */
$plugin = $this->manager
->createInstance($form_state
->getValue('plugin'));
$plugin_uuid = $this->linkitProfile
->addMatcher($plugin
->getConfiguration());
$this->linkitProfile
->save();
$this
->logger('linkit')
->notice('Added %label matcher to the @profile profile.', [
'%label' => $this->linkitProfile
->getMatcher($plugin_uuid)
->getLabel(),
'@profile' => $this->linkitProfile
->label(),
]);
$is_configurable = $plugin instanceof ConfigurableMatcherInterface;
if ($is_configurable) {
$form_state
->setRedirect('linkit.matcher.edit', [
'linkit_profile' => $this->linkitProfile
->id(),
'plugin_instance_id' => $plugin_uuid,
]);
}
else {
drupal_set_message($this
->t('Added %label matcher.', [
'%label' => $plugin
->getLabel(),
]));
$form_state
->setRedirect('linkit.matchers', [
'linkit_profile' => $this->linkitProfile
->id(),
]);
}
}