Including security review as a submodule - with patched for Yaffs.
[yaffs-website] / web / modules / contrib / security_review / src / CheckSettings.php
1 <?php
2
3 /**
4  * @file
5  * Contains \Drupal\security_review\CheckSettings.
6  */
7
8 namespace Drupal\security_review;
9
10 use Drupal\Core\Config\Config;
11
12 /**
13  * Defines the default implementation of CheckSettingsInterface.
14  */
15 class CheckSettings implements CheckSettingsInterface {
16
17   /**
18    * The parent check.
19    *
20    * @var \Drupal\security_review\Check
21    */
22   protected $check;
23
24   /**
25    * The configuration storage of the parent Check.
26    *
27    * @var \Drupal\Core\Config\Config $config
28    */
29   protected $config;
30
31   /**
32    * Creates a CheckSettings instance.
33    *
34    * @param \Drupal\security_review\Check $check
35    *   The parent Check.
36    * @param \Drupal\Core\Config\Config $config
37    *   The parent Check's configuration.
38    */
39   public function __construct(Check $check, Config &$config) {
40     $this->check = $check;
41     $this->config = $config;
42   }
43
44   /**
45    * {@inheritdoc}
46    */
47   public function get($key, $default_value = NULL) {
48     $value = $this->config->get('settings.' . $key);
49
50     if ($value == NULL) {
51       return $default_value;
52     }
53     return $value;
54   }
55
56   /**
57    * {@inheritdoc}
58    */
59   public function set($key, $value) {
60     $this->config->set('settings.' . $key, $value);
61     $this->config->save();
62     return $this;
63   }
64
65   /**
66    * {@inheritdoc}
67    */
68   public function buildForm() {
69     return [];
70   }
71
72   /**
73    * {@inheritdoc}
74    */
75   public function validateForm(array &$form, array $values) {
76     // Validation is optional.
77   }
78
79   /**
80    * {@inheritdoc}
81    */
82   public function submitForm(array &$form, array $values) {
83     // Handle submission.
84   }
85
86 }