PluginProbe
User Access Manager / 2.2.3
User Access Manager v2.2.3
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 +79 -6 2.3.132.2.3 View file →
@@ -1,5 +1,18 @@
1 1 <?php
2 +/**
3 + * TermMembershipHandler.php
4 + *
5 + * The TermMembershipHandler class file.
6 + *
7 + * PHP versions 5
8 + *
9 + * @author Alexander Schneider <alexanderschneider85@gmail.com>
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 + */
2 15
3 16 declare(strict_types=1);
4 17
5 18 namespace UserAccessManager\ObjectMembership;
@@ -11,22 +24,63 @@
11 24 use UserAccessManager\UserGroup\AssignmentInformation;
12 25 use UserAccessManager\UserGroup\AssignmentInformationFactory;
13 26 use UserAccessManager\Wrapper\Wordpress;
14 27
28 +/**
29 + * Class TermMembershipHandler
30 + *
31 + * @package UserAccessManager\UserGroup
32 + */
15 33 class TermMembershipHandler extends ObjectMembershipWithMapHandler
16 34 {
17 - protected ?string $generalObjectType = ObjectHandler::GENERAL_TERM_OBJECT_TYPE;
35 + /**
36 + * @var string
37 + */
38 + protected $generalObjectType = ObjectHandler::GENERAL_TERM_OBJECT_TYPE;
18 39
40 + /**
41 + * @var Wordpress
42 + */
43 + private $wordpress;
44 +
45 + /**
46 + * @var ObjectHandler
47 + */
48 + private $objectHandler;
49 +
50 + /**
51 + * @var ObjectMapHandler
52 + */
53 + private $objectMapHandler;
54 +
55 + /**
56 + * TermMembershipHandler constructor.
57 + * @param AssignmentInformationFactory $assignmentInformationFactory
58 + * @param Wordpress $wordpress
59 + * @param ObjectHandler $objectHandler
60 + * @param ObjectMapHandler $objectMapHandler
61 + * @throws Exception
62 + */
19 63 public function __construct(
20 64 AssignmentInformationFactory $assignmentInformationFactory,
21 - private Wordpress $wordpress,
22 - private ObjectHandler $objectHandler,
23 - private ObjectMapHandler $objectMapHandler
65 + Wordpress $wordpress,
66 + ObjectHandler $objectHandler,
67 + ObjectMapHandler $objectMapHandler
24 68 ) {
25 69 parent::__construct($assignmentInformationFactory);
70 +
71 + $this->wordpress = $wordpress;
72 + $this->objectHandler = $objectHandler;
73 + $this->objectMapHandler = $objectMapHandler;
26 74 }
27 75
28 - public function getObjectName(int|string|null $objectId, string &$typeName = ''): int|string
76 + /**
77 + * Returns the object and type name.
78 + * @param int|string $objectId
79 + * @param string $typeName
80 + * @return int|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,8 +91,12 @@
37 91
38 92 return $objectId;
39 93 }
40 94
95 + /**
96 + * Returns the handled objects.
97 + * @return array
98 + */
41 99 public function getHandledObjects(): array
42 100 {
43 101 $keys = array_keys($this->objectHandler->getTaxonomies());
44 102 return array_merge(parent::getHandledObjects(), array_combine($keys, $keys));
@@ -43,8 +101,12 @@
43 101 $keys = array_keys($this->objectHandler->getTaxonomies());
44 102 return array_merge(parent::getHandledObjects(), array_combine($keys, $keys));
45 103 }
46 104
105 + /**
106 + * Returns the map.
107 + * @return array
108 + */
47 109 protected function getMap(): array
48 110 {
49 111 return $this->objectMapHandler->getTermTreeMap();
50 112 }
@@ -49,14 +111,20 @@
49 111 return $this->objectMapHandler->getTermTreeMap();
50 112 }
51 113
52 114 /**
115 + * Checks if the term is a member of the user group.
116 + * @param AbstractUserGroup $userGroup
117 + * @param bool $lockRecursive
118 + * @param int|string $objectId
119 + * @param null|AssignmentInformation $assignmentInformation
120 + * @return bool
53 121 * @throws Exception
54 122 */
55 123 public function isMember(
56 124 AbstractUserGroup $userGroup,
57 125 bool $lockRecursive,
58 - int|string|null $objectId,
126 + $objectId,
59 127 ?AssignmentInformation &$assignmentInformation = null
60 128 ): bool {
61 129 return $this->getMembershipByMap($userGroup, $lockRecursive, $objectId, $assignmentInformation);
62 130 }
@@ -61,8 +129,13 @@
61 129 return $this->getMembershipByMap($userGroup, $lockRecursive, $objectId, $assignmentInformation);
62 130 }
63 131
64 132 /**
133 + * Returns the term role objects.
134 + * @param AbstractUserGroup $userGroup
135 + * @param bool $lockRecursive
136 + * @param null $objectType
137 + * @return array
65 138 * @throws Exception
66 139 */
67 140 public function getFullObjects(AbstractUserGroup $userGroup, bool $lockRecursive, $objectType = null): array
68 141 {