public function PhantomJSCaptureTestForm::submitForm in PhantomJS Capture 8
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/ PhantomJSCaptureTestForm.php, line 93
Class
- PhantomJSCaptureTestForm
- Class PhantomJSCaptureTestForm
Namespace
Drupal\phantomjs_capture\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$config = $this
->config('phantomjs_capture.settings');
$values = $form_state
->getValues();
$url = Url::fromUri($values['url']);
$file = 'capture_test' . $values['format'];
$destination = \Drupal::config('system.file')
->get('default_scheme') . '://' . $config
->get('destination') . '/test/' . REQUEST_TIME;
$file_url = file_create_url($destination . '/' . $file);
if ($this->captureHelper
->capture($url, $destination, $file)) {
drupal_set_message($this
->t('The file has been generated! You can view it <a href=":url">here</a>', array(
':url' => $file_url,
)));
}
else {
drupal_set_message('The address entered could not be retrieved, directory was not writeable, or phantomjs could not perform the action requested.', 'error');
}
}