function FormState::isRequestMethodSafe

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/Form/FormState.php \Drupal\Core\Form\FormState::isRequestMethodSafe()
  2. 10 core/lib/Drupal/Core/Form/FormState.php \Drupal\Core\Form\FormState::isRequestMethodSafe()
  3. 11.x core/lib/Drupal/Core/Form/FormState.php \Drupal\Core\Form\FormState::isRequestMethodSafe()

Checks whether the request method is a "safe" HTTP method.

Link below defines GET and HEAD as "safe" methods, meaning they SHOULD NOT have side-effects, such as persisting $form_state changes.

Return value

bool

See also

\Symfony\Component\HttpFoundation\Request::isMethodSafe()

http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.1.1

1 call to FormState::isRequestMethodSafe()
FormState::setCached in core/lib/Drupal/Core/Form/FormState.php
Sets this form to be cached.

File

core/lib/Drupal/Core/Form/FormState.php, line 645

Class

FormState
Stores information about the state of a form.

Namespace

Drupal\Core\Form

Code

protected function isRequestMethodSafe() {
    return in_array($this->requestMethod, [
        'GET',
        'HEAD',
    ]);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.