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 / Policy / Factory.php
Factory.php
82 lines 2.0 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 * AAM core policy manager factory
12 *
13 * @since 6.1.0 Fixed bug with incorrectly managed internal cache
14 * @since 6.0.0 Initial implementation of the class
15 *
16 * @package AAM
17 * @version 6.1.0
18 */
19 final class AAM_Core_Policy_Factory
20 {
21
22 /**
23 * Collection of policy manage instances
24 *
25 * @var array
26 *
27 * @access private
28 * @version 6.0.0
29 */
30 private static $_instances = array();
31
32 /**
33 * Get single instance of access manager
34 *
35 * @param AAM_Core_Subject $subject
36 * @param boolean $skipInheritance
37 *
38 * @return AAM_Core_Policy_Manager
39 *
40 * @since 6.1.0 Fixed bug with incorrectly managed internal caching
41 * @since 6.0.0 Initial implementation of the method
42 *
43 * @access public
44 * @version 6.1.0
45 */
46 public static function get(AAM_Core_Subject $subject = null, $skipInheritance)
47 {
48 if (is_null($subject)) {
49 $subject = AAM::getUser();
50 }
51
52 $id = $subject->getId();
53
54 $sid = $subject::UID . (empty($id) ? '' : '_' . $id);
55 $sid .= ($skipInheritance ? '_direct' : '_complete');
56
57 if (!isset(self::$_instances[$sid])) {
58 self::$_instances[$sid] = new AAM_Core_Policy_Manager(
59 $subject, $skipInheritance
60 );
61
62 // Parse all attached to the user policies
63 self::$_instances[$sid]->initialize();
64 }
65
66 return self::$_instances[$sid];
67 }
68
69 /**
70 * Reset internal cache
71 *
72 * @return void
73 *
74 * @access public
75 * @version 6.0.0
76 */
77 public static function reset()
78 {
79 self::$_instances = array();
80 }
81
82 }