PluginProbe
User Access Manager / 2.1.11
User Access Manager v2.1.11
2.3.20 2.3.19 2.3.18 2.3.17 2.3.16 2.3.15 2.3.14 2.3.13 trunk 0.6 0.6.1 0.6.2 0.7 0.7 Beta 0.7.0.1 0.8 0.8.0.1 0.8.0.2 0.9 0.9.1 0.9.1.1 0.9.1.2 0.9.1.3 0.9.1.4 1.0 All 136 releases
← All changes | src/ObjectMembership/TermMembershipHandler.php +93 -20 2.3.14 → 2.1.11 View file →
@@ -1,11 +1,20 @@
1 1 <?php
2 -
3 -declare(strict_types=1);
4 -
2 +/**
3 + * TermMembershipHandler.php
4 + *
5 + * The TermMembershipHandler class file.
6 + *
7 + * PHP versions 5
8 + *
9 + * @author Alexander Schneider <[email protected]>
10 + * @copyright 2008-2017 Alexander Schneider
11 + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2
12 + * @version SVN: $id$
13 + * @link http://wordpress.org/extend/plugins/user-access-manager/
14 + */
5 15 namespace UserAccessManager\ObjectMembership;
6 16
7 -use Exception;
8 17 use UserAccessManager\Object\ObjectHandler;
9 18 use UserAccessManager\Object\ObjectMapHandler;
10 19 use UserAccessManager\UserGroup\AbstractUserGroup;
11 20 use UserAccessManager\UserGroup\AssignmentInformation;
@@ -11,22 +20,67 @@
11 20 use UserAccessManager\UserGroup\AssignmentInformation;
12 21 use UserAccessManager\UserGroup\AssignmentInformationFactory;
13 22 use UserAccessManager\Wrapper\Wordpress;
14 23
24 +/**
25 + * Class TermMembershipHandler
26 + *
27 + * @package UserAccessManager\UserGroup
28 + */
15 29 class TermMembershipHandler extends ObjectMembershipWithMapHandler
16 30 {
17 - protected ?string $generalObjectType = ObjectHandler::GENERAL_TERM_OBJECT_TYPE;
31 + /**
32 + * @var string
33 + */
34 + protected $generalObjectType = ObjectHandler::GENERAL_TERM_OBJECT_TYPE;
18 35
36 + /**
37 + * @var Wordpress
38 + */
39 + private $wordpress;
40 +
41 + /**
42 + * @var ObjectHandler
43 + */
44 + private $objectHandler;
45 +
46 + /**
47 + * @var ObjectMapHandler
48 + */
49 + private $objectMapHandler;
50 +
51 + /**
52 + * TermMembershipHandler constructor.
53 + *
54 + * @param AssignmentInformationFactory $assignmentInformationFactory
55 + * @param Wordpress $wordpress
56 + * @param ObjectHandler $objectHandler
57 + * @param ObjectMapHandler $objectMapHandler
58 + *
59 + * @throws \Exception
60 + */
19 61 public function __construct(
20 62 AssignmentInformationFactory $assignmentInformationFactory,
21 - private Wordpress $wordpress,
22 - private ObjectHandler $objectHandler,
23 - private ObjectMapHandler $objectMapHandler
63 + Wordpress $wordpress,
64 + ObjectHandler $objectHandler,
65 + ObjectMapHandler $objectMapHandler
24 66 ) {
25 67 parent::__construct($assignmentInformationFactory);
68 +
69 + $this->wordpress = $wordpress;
70 + $this->objectHandler = $objectHandler;
71 + $this->objectMapHandler = $objectMapHandler;
26 72 }
27 73
28 - public function getObjectName(int|string|null $objectId, string &$typeName = ''): int|string
74 + /**
75 + * Returns the object and type name.
76 + *
77 + * @param string $objectId
78 + * @param string $typeName
79 + *
80 + * @return string
81 + */
82 + public function getObjectName($objectId, &$typeName = '')
29 83 {
30 84 $term = $this->objectHandler->getTerm($objectId);
31 85
32 86 if ($term !== false) {
@@ -37,35 +91,54 @@
37 91
38 92 return $objectId;
39 93 }
40 94
41 - public function getHandledObjects(): array
95 + /**
96 + * Returns the handled objects.
97 + *
98 + * @return array
99 + */
100 + public function getHandledObjects()
42 101 {
43 102 $keys = array_keys($this->objectHandler->getTaxonomies());
44 103 return array_merge(parent::getHandledObjects(), array_combine($keys, $keys));
45 104 }
46 105
47 - protected function getMap(): array
106 + /**
107 + * Returns the map.
108 + *
109 + * @return array
110 + */
111 + protected function getMap()
48 112 {
49 113 return $this->objectMapHandler->getTermTreeMap();
50 114 }
51 115
52 116 /**
53 - * @throws Exception
117 + * Checks if the term is a member of the user group.
118 + *
119 + * @param AbstractUserGroup $userGroup
120 + * @param bool $lockRecursive
121 + * @param string $objectId
122 + * @param null|AssignmentInformation $assignmentInformation
123 + *
124 + * @return bool
54 125 */
55 - public function isMember(
56 - AbstractUserGroup $userGroup,
57 - bool $lockRecursive,
58 - int|string|null $objectId,
59 - ?AssignmentInformation &$assignmentInformation = null
60 - ): bool {
126 + public function isMember(AbstractUserGroup $userGroup, $lockRecursive, $objectId, &$assignmentInformation = null)
127 + {
61 128 return $this->getMembershipByMap($userGroup, $lockRecursive, $objectId, $assignmentInformation);
62 129 }
63 130
64 131 /**
65 - * @throws Exception
132 + * Returns the term role objects.
133 + *
134 + * @param AbstractUserGroup $userGroup
135 + * @param bool $lockRecursive
136 + * @param null $objectType
137 + *
138 + * @return array
66 139 */
67 - public function getFullObjects(AbstractUserGroup $userGroup, bool $lockRecursive, $objectType = null): array
140 + public function getFullObjects(AbstractUserGroup $userGroup, $lockRecursive, $objectType = null)
68 141 {
69 142 $objectType = ($objectType === null) ? $this->generalObjectType : $objectType;
70 143 return $this->getFullObjectsByMap($userGroup, $lockRecursive, $objectType);
71 144 }