PluginProbe
Advanced Access Manager – Access Governance for WordPress / 6.9.0
Advanced Access Manager – Access Governance for WordPress v6.9.0
7.1.4 7.1.2 7.1.3 6.8.4 6.8.5 6.9.0 6.9.1 6.9.10 6.9.11 6.9.12 6.9.13 6.9.14 6.9.15 6.9.16 6.9.17 6.9.18 6.9.19 6.9.2 6.9.20 6.9.21 6.9.22 6.9.23 6.9.24 6.9.25 6.9.26 All 210 releases
advanced-access-manager / application / Core / Contract / ServiceTrait.php
ServiceTrait.php
94 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * ======================================================================
5 * LICENSE: This file is subject to the terms and conditions defined in *
6 * file 'license.txt', which is part of this source code package. *
7 * ======================================================================
8 */
9
10 /**
11 * Reusable elements for each service
12 *
13 * @since 6.7.9 https://github.com/aamplugin/advanced-access-manager/issues/193
14 * @since 6.4.0 Enhancement https://github.com/aamplugin/advanced-access-manager/issues/71
15 * @since 6.0.0 Initial implementation of the service
16 *
17 * @package AAM
18 * @version 6.7.9
19 */
20 trait AAM_Core_Contract_ServiceTrait
21 {
22
23 /**
24 * Single instance of itself
25 *
26 * @var object
27 *
28 * @access protected
29 * @version 6.0.0
30 */
31 protected static $instance = null;
32
33 /**
34 * Register service to be fetched
35 *
36 * @return null|object
37 *
38 * @access protected
39 * @version 6.4.0
40 */
41 protected function registerService()
42 {
43 add_filter('aam_get_service_filter', function($service, $alias) {
44 if (empty($service) && ($alias === self::SERVICE_ALIAS)) {
45 $service = $this;
46 }
47
48 return $service;
49 }, 10, 2);
50 }
51
52 /**
53 * Bootstrap the service
54 *
55 * @return void
56 *
57 * @param boolean $reload
58 *
59 * @since 6.7.9 https://github.com/aamplugin/advanced-access-manager/issues/193
60 * @since 6.0.0 Initial implementation of the method
61 *
62 * @access public
63 * @version 6.7.9
64 */
65 public static function bootstrap($reload = false)
66 {
67 if (is_null(self::$instance) || $reload) {
68 self::$instance = new self;
69 }
70 }
71
72 /**
73 * Get single instance of itself
74 *
75 * @return object
76 *
77 * @param boolean $reload
78 *
79 * @since 6.7.9 https://github.com/aamplugin/advanced-access-manager/issues/193
80 * @since 6.0.0 Initial implementation of the method
81 *
82 * @access public
83 * @version 6.7.9
84 */
85 public static function getInstance($reload = false)
86 {
87 if (is_null(self::$instance) || $reload) {
88 self::bootstrap($reload);
89 }
90
91 return self::$instance;
92 }
93
94 }