PluginProbe
User Access Manager / 2.3.18
User Access Manager v2.3.18
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
user-access-manager / src / UserGroup / UserGroupFactory.php

UserGroupFactory.php in User Access Manager 2.3.18, at src/UserGroup/UserGroupFactory.php

65 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare(strict_types=1);
4
5 namespace UserAccessManager\UserGroup;
6
7 use UserAccessManager\Config\MainConfig;
8 use UserAccessManager\Database\Database;
9 use UserAccessManager\Object\ObjectHandler;
10 use UserAccessManager\Wrapper\Wordpress;
11
12 class UserGroupFactory
13 {
14 public function __construct(
15 private Wordpress $wordpress,
16 private Database $database,
17 private MainConfig $config,
18 private ObjectHandler $objectHandler,
19 private AssignedObjectsLoader $assignedObjectsLoader
20 ) {
21 }
22
23 /**
24 * @throws UserGroupTypeException
25 */
26 public function createUserGroup(int|string|null $id = null): UserGroup
27 {
28 return new UserGroup(
29 $this->wordpress,
30 $this->database,
31 $this->config,
32 $this->objectHandler,
33 $this->assignedObjectsLoader,
34 $id
35 );
36 }
37
38 /**
39 * @throws UserGroupTypeException
40 */
41 public function createUserGroupFromDatabaseRow(object $databaseUserGroup): UserGroup
42 {
43 $userGroup = $this->createUserGroup();
44 $userGroup->assignDatabaseValues($databaseUserGroup);
45
46 return $userGroup;
47 }
48
49 /**
50 * @throws UserGroupTypeException
51 */
52 public function createDynamicUserGroup(string $type, int|string $id): DynamicUserGroup
53 {
54 return new DynamicUserGroup(
55 $this->wordpress,
56 $this->database,
57 $this->config,
58 $this->objectHandler,
59 $this->assignedObjectsLoader,
60 $type,
61 $id
62 );
63 }
64 }
65