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/UserGroup/UserGroupFactory.php +88 -22 2.3.162.2.3 View file →
@@ -1,5 +1,18 @@
1 1 <?php
2 +/**
3 + * UserGroupFactory.php
4 + *
5 + * The UserGroupFactory 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\UserGroup;
@@ -10,25 +23,85 @@
10 23 use UserAccessManager\Util\Util;
11 24 use UserAccessManager\Wrapper\Php;
12 25 use UserAccessManager\Wrapper\Wordpress;
13 26
27 +/**
28 + * Class UserGroupFactory
29 + *
30 + * @package UserAccessManager\UserGroup
31 + */
14 32 class UserGroupFactory
15 33 {
34 + /**
35 + * @var Php
36 + */
37 + private $php;
38 +
39 + /**
40 + * @var Wordpress
41 + */
42 + private $wordpress;
43 +
44 + /**
45 + * @var Database
46 + */
47 + private $database;
48 +
49 + /**
50 + * @var MainConfig
51 + */
52 + private $config;
53 +
54 + /**
55 + * @var Util
56 + */
57 + private $util;
58 +
59 + /**
60 + * @var ObjectHandler
61 + */
62 + private $objectHandler;
63 +
64 + /**
65 + * @var AssignmentInformationFactory
66 + */
67 + private $assignmentInformationFactory;
68 +
69 + /**
70 + * UserGroupFactory constructor.
71 + * @param Php $php
72 + * @param Wordpress $wordpress
73 + * @param Database $database
74 + * @param MainConfig $config
75 + * @param Util $util
76 + * @param ObjectHandler $objectHandler
77 + * @param AssignmentInformationFactory $assignmentInformationFactory
78 + */
16 79 public function __construct(
17 - private Php $php,
18 - private Wordpress $wordpress,
19 - private Database $database,
20 - private MainConfig $config,
21 - private Util $util,
22 - private ObjectHandler $objectHandler,
23 - private AssignedObjectsLoader $assignedObjectsLoader
80 + Php $php,
81 + Wordpress $wordpress,
82 + Database $database,
83 + MainConfig $config,
84 + Util $util,
85 + ObjectHandler $objectHandler,
86 + AssignmentInformationFactory $assignmentInformationFactory
24 87 ) {
88 + $this->php = $php;
89 + $this->wordpress = $wordpress;
90 + $this->database = $database;
91 + $this->config = $config;
92 + $this->util = $util;
93 + $this->objectHandler = $objectHandler;
94 + $this->assignmentInformationFactory = $assignmentInformationFactory;
25 95 }
26 96
27 97 /**
98 + * Creates a new user group object.
99 + * @param null|string $id
100 + * @return UserGroup
28 101 * @throws UserGroupTypeException
29 102 */
30 - public function createUserGroup(int|string|null $id = null): UserGroup
103 + public function createUserGroup($id = null): UserGroup
31 104 {
32 105 return new UserGroup(
33 106 $this->php,
34 107 $this->wordpress,
@@ -35,29 +108,22 @@
35 108 $this->database,
36 109 $this->config,
37 110 $this->util,
38 111 $this->objectHandler,
39 - $this->assignedObjectsLoader,
112 + $this->assignmentInformationFactory,
40 113 $id
41 114 );
42 115 }
43 116
44 117 /**
118 + * Creates a new dynamic user group object.
119 + * @param string $type
120 + * @param int|string $id
121 + * @return DynamicUserGroup
45 122 * @throws UserGroupTypeException
46 123 */
47 - public function createUserGroupFromDatabaseRow(object $databaseUserGroup): UserGroup
124 + public function createDynamicUserGroup(string $type, $id): DynamicUserGroup
48 125 {
49 - $userGroup = $this->createUserGroup();
50 - $userGroup->assignDatabaseValues($databaseUserGroup);
51 -
52 - return $userGroup;
53 - }
54 -
55 - /**
56 - * @throws UserGroupTypeException
57 - */
58 - public function createDynamicUserGroup(string $type, int|string $id): DynamicUserGroup
59 - {
60 126 return new DynamicUserGroup(
61 127 $this->php,
62 128 $this->wordpress,
63 129 $this->database,
@@ -63,9 +129,9 @@
63 129 $this->database,
64 130 $this->config,
65 131 $this->util,
66 132 $this->objectHandler,
67 - $this->assignedObjectsLoader,
133 + $this->assignmentInformationFactory,
68 134 $type,
69 135 $id
70 136 );
71 137 }