Added another front page space for Yaffs info. Added roave security for composer.
[yaffs-website] / web / core / lib / Drupal / Core / Render / Element / Token.php
1 <?php
2
3 namespace Drupal\Core\Render\Element;
4
5 use Drupal\Core\Form\FormStateInterface;
6
7 /**
8  * Stores token data in a hidden form field.
9  *
10  * This is generally used to protect against cross-site forgeries. A token
11  * element is automatically added to each Drupal form by an implementation of
12  * \Drupal\Core\Form\FormBuilderInterface::prepareForm() so you don't generally
13  * have to add one yourself.
14  *
15  * @FormElement("token")
16  */
17 class Token extends Hidden {
18
19   /**
20    * {@inheritdoc}
21    */
22   public function getInfo() {
23     $class = get_class($this);
24     return [
25       '#input' => TRUE,
26       '#pre_render' => [
27         [$class, 'preRenderHidden'],
28       ],
29       '#theme' => 'input__hidden',
30     ];
31   }
32
33   /**
34    * {@inheritdoc}
35    */
36   public static function valueCallback(&$element, $input, FormStateInterface $form_state) {
37     if ($input !== FALSE && $input !== NULL) {
38       // This should be a string, but allow other scalars since they might be
39       // valid input in programmatic form submissions.
40       return is_scalar($input) ? (string) $input : '';
41     }
42     return NULL;
43   }
44
45 }