-
Notifications
You must be signed in to change notification settings - Fork 341
Expand file tree
/
Copy pathModule_With_Settings_Trait.php
More file actions
55 lines (49 loc) · 1000 Bytes
/
Module_With_Settings_Trait.php
File metadata and controls
55 lines (49 loc) · 1000 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
/**
* Trait Google\Site_Kit\Core\Modules\Module_With_Settings_Trait
*
* @package Google\Site_Kit
* @copyright 2021 Google LLC
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @link https://sitekit.withgoogle.com
*/
namespace Google\Site_Kit\Core\Modules;
/**
* Trait for a module that includes a screen.
*
* @since 1.2.0
* @template T of Module_Settings
* @access private
* @ignore
*/
trait Module_With_Settings_Trait {
/**
* Settings instance.
*
* @since 1.2.0
*
* @var T
*/
protected $settings;
/**
* Sets up the module's settings instance.
*
* @since 1.2.0
*
* @return T
*/
abstract protected function setup_settings();
/**
* Gets the module's Settings instance.
*
* @since 1.2.0
*
* @return T Module_Settings instance.
*/
public function get_settings() {
if ( ! $this->settings instanceof Module_Settings ) {
$this->settings = $this->setup_settings();
}
return $this->settings;
}
}