Updated all the contrib modules to their latest versions.
[yaffs-website] / web / modules / contrib / memcache / src / MemcacheSettings.php
1 <?php
2
3 namespace Drupal\memcache;
4
5 use Drupal\Core\Site\Settings;
6
7 /**
8  * Class for holding Memcache related config.
9  */
10 class MemcacheSettings {
11
12   /**
13    * Array with the settings.
14    *
15    * @var array
16    */
17   protected $settings = [];
18
19   /**
20    * Constructor.
21    *
22    * @param \Drupal\Core\Site\Settings $settings
23    *   The site settings instance.
24    */
25   public function __construct(Settings $settings) {
26     $this->settings = $settings->get('memcache', []);
27   }
28
29   /**
30    * Returns a memcache setting.
31    *
32    * Settings can be set in settings.php in the $settings['memcache'] array and
33    * requested by this function. Settings should be used over configuration for
34    * read-only, possibly low bootstrap configuration that is environment
35    * specific.
36    *
37    * @param string $name
38    *   The name of the setting to return.
39    * @param mixed $default
40    *   (optional) The default value to use if this setting is not set.
41    *
42    * @return mixed
43    *   The value of the setting, the provided default if not set.
44    */
45   public function get($name, $default = NULL) {
46     return isset($this->settings[$name]) ? $this->settings[$name] : $default;
47   }
48
49   /**
50    * Returns all Memcache settings.
51    *
52    * @return array
53    *   All settings.
54    */
55   public function getAll() {
56     return $this->settings;
57   }
58
59 }