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