public function Sharrre::validateConfigurationForm in Share Message 8
Form validation handler.
Parameters
array $form: An associative array containing the structure of the plugin form as built by static::buildConfigurationForm().
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form. Calling code should pass on a subform state created through \Drupal\Core\Form\SubformState::createForSubform().
Overrides SharePluginBase::validateConfigurationForm
File
- src/
Plugin/ sharemessage/ Sharrre.php, line 222
Class
- Sharrre
- Sharrre plugin.
Namespace
Drupal\sharemessage\Plugin\sharemessageCode
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
$sharrre_config = \Drupal::config('sharemessage.sharrre');
$library_exists = FALSE;
// Check if the library module is enabled and if the library is present.
if (\Drupal::moduleHandler()
->moduleExists('libraries')) {
$directory = libraries_get_path('sharrre');
$file = 'jquery.sharrre.min.js';
if (file_exists($directory . '/' . $file)) {
$library_exists = TRUE;
}
}
// General error if neither the library nor the URL from configuration exist.
if (!$library_exists && !$sharrre_config
->get('library_url')) {
$form_state
->setErrorByName('plugin', t('Either set the library locally (in /libraries/sharrre) and enable the libraries module or enter the remote URL on <a href=":sharrre_settings">Sharrre settings page</a>.', [
':sharrre_settings' => Url::fromRoute('sharemessage.sharrre.settings')
->toString(),
]));
}
}