Condition.php
6 years ago
Factory.php
6 years ago
Manager.php
6 years ago
Token.php
6 years ago
Validator.php
6 years ago
Factory.php
54 lines
| 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 | * @package AAM |
| 14 | * @author Vasyl Martyniuk <vasyl@vasyltech.com> |
| 15 | * @since AAM v5.7.2 |
| 16 | */ |
| 17 | final class AAM_Core_Policy_Factory { |
| 18 | |
| 19 | /** |
| 20 | * Collection of instances |
| 21 | * |
| 22 | * @var array |
| 23 | * |
| 24 | * @access private |
| 25 | * @static |
| 26 | */ |
| 27 | private static $_instances = array(); |
| 28 | |
| 29 | /** |
| 30 | * Get single instance of itself |
| 31 | * |
| 32 | * @param AAM_Core_Subject $subject |
| 33 | * |
| 34 | * @return AAM_Core_Policy_Manager |
| 35 | * |
| 36 | * @access public |
| 37 | * @static |
| 38 | */ |
| 39 | public static function get(AAM_Core_Subject $subject = null) { |
| 40 | if (is_null($subject)) { |
| 41 | $subject = AAM::getUser(); |
| 42 | } |
| 43 | |
| 44 | $id = $subject->getId(); |
| 45 | $sid = $subject->getUID() . (empty($id) ? '' : '_' . $id); |
| 46 | |
| 47 | if (!isset(self::$_instances[$sid])) { |
| 48 | self::$_instances[$sid] = new AAM_Core_Policy_Manager($subject); |
| 49 | } |
| 50 | |
| 51 | return self::$_instances[$sid]; |
| 52 | } |
| 53 | |
| 54 | } |