function FormCache::getCache

Same name in other branches
  1. 9 core/lib/Drupal/Core/Form/FormCache.php \Drupal\Core\Form\FormCache::getCache()
  2. 8.9.x core/lib/Drupal/Core/Form/FormCache.php \Drupal\Core\Form\FormCache::getCache()
  3. 10 core/lib/Drupal/Core/Form/FormCache.php \Drupal\Core\Form\FormCache::getCache()

Overrides FormCacheInterface::getCache

File

core/lib/Drupal/Core/Form/FormCache.php, line 119

Class

FormCache
Encapsulates the caching of a form and its form state.

Namespace

Drupal\Core\Form

Code

public function getCache($form_build_id, FormStateInterface $form_state) {
    if ($form = $this->keyValueExpirableFactory
        ->get('form')
        ->get($form_build_id)) {
        if (isset($form['#cache_token']) && $this->csrfToken
            ->validate($form['#cache_token']) || !isset($form['#cache_token']) && $this->currentUser
            ->isAnonymous()) {
            $this->loadCachedFormState($form_build_id, $form_state);
            return $form;
        }
    }
}

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