Complex classes like UserService often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use UserService, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 63 | class UserService implements UserServiceInterface |
||
| 64 | { |
||
| 65 | /** @var \eZ\Publish\API\Repository\Repository */ |
||
| 66 | protected $repository; |
||
| 67 | |||
| 68 | /** @var \eZ\Publish\SPI\Persistence\User\Handler */ |
||
| 69 | protected $userHandler; |
||
| 70 | |||
| 71 | /** @var \eZ\Publish\SPI\Persistence\Content\Location\Handler */ |
||
| 72 | private $locationHandler; |
||
| 73 | |||
| 74 | /** @var array */ |
||
| 75 | protected $settings; |
||
| 76 | |||
| 77 | /** @var \Psr\Log\LoggerInterface|null */ |
||
| 78 | protected $logger; |
||
| 79 | |||
| 80 | /** @var \eZ\Publish\API\Repository\PermissionResolver */ |
||
| 81 | private $permissionResolver; |
||
| 82 | |||
| 83 | /** @var \eZ\Publish\Core\Repository\User\PasswordHashServiceInterface */ |
||
| 84 | private $passwordHashService; |
||
| 85 | |||
| 86 | public function setLogger(LoggerInterface $logger = null) |
||
| 90 | |||
| 91 | /** |
||
| 92 | * Setups service with reference to repository object that created it & corresponding handler. |
||
| 93 | * |
||
| 94 | * @param \eZ\Publish\API\Repository\Repository $repository |
||
| 95 | * @param \eZ\Publish\SPI\Persistence\User\Handler $userHandler |
||
| 96 | * @param \eZ\Publish\SPI\Persistence\Content\Location\Handler $locationHandler |
||
| 97 | * @param array $settings |
||
| 98 | */ |
||
| 99 | public function __construct( |
||
| 121 | |||
| 122 | /** |
||
| 123 | * Creates a new user group using the data provided in the ContentCreateStruct parameter. |
||
| 124 | * |
||
| 125 | * In 4.x in the content type parameter in the profile is ignored |
||
| 126 | * - the content type is determined via configuration and can be set to null. |
||
| 127 | * The returned version is published. |
||
| 128 | * |
||
| 129 | * @param \eZ\Publish\API\Repository\Values\User\UserGroupCreateStruct $userGroupCreateStruct a structure for setting all necessary data to create this user group |
||
| 130 | * @param \eZ\Publish\API\Repository\Values\User\UserGroup $parentGroup |
||
| 131 | * |
||
| 132 | * @return \eZ\Publish\API\Repository\Values\User\UserGroup |
||
| 133 | * |
||
| 134 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to create a user group |
||
| 135 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if the input structure has invalid data |
||
| 136 | * @throws \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException if a field in the $userGroupCreateStruct is not valid |
||
| 137 | * @throws \eZ\Publish\API\Repository\Exceptions\ContentValidationException if a required field is missing or set to an empty value |
||
| 138 | */ |
||
| 139 | public function createUserGroup(APIUserGroupCreateStruct $userGroupCreateStruct, APIUserGroup $parentGroup) |
||
| 172 | |||
| 173 | /** |
||
| 174 | * Loads a user group for the given id. |
||
| 175 | * |
||
| 176 | * @param mixed $id |
||
| 177 | * @param string[] $prioritizedLanguages Used as prioritized language code on translated properties of returned object. |
||
| 178 | * |
||
| 179 | * @return \eZ\Publish\API\Repository\Values\User\UserGroup |
||
| 180 | * |
||
| 181 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to create a user group |
||
| 182 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException if the user group with the given id was not found |
||
| 183 | */ |
||
| 184 | public function loadUserGroup($id, array $prioritizedLanguages = []) |
||
| 190 | |||
| 191 | /** |
||
| 192 | * Loads the sub groups of a user group. |
||
| 193 | * |
||
| 194 | * @param \eZ\Publish\API\Repository\Values\User\UserGroup $userGroup |
||
| 195 | * @param int $offset the start offset for paging |
||
| 196 | * @param int $limit the number of user groups returned |
||
| 197 | * @param string[] $prioritizedLanguages Used as prioritized language code on translated properties of returned object. |
||
| 198 | * |
||
| 199 | * @return \eZ\Publish\API\Repository\Values\User\UserGroup[] |
||
| 200 | * |
||
| 201 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to read the user group |
||
| 202 | */ |
||
| 203 | public function loadSubUserGroups(APIUserGroup $userGroup, $offset = 0, $limit = 25, array $prioritizedLanguages = []) |
||
| 237 | |||
| 238 | /** |
||
| 239 | * Returns (searches) subgroups of a user group described by its main location. |
||
| 240 | * |
||
| 241 | * @param \eZ\Publish\API\Repository\Values\Content\Location $location |
||
| 242 | * @param int $offset |
||
| 243 | * @param int $limit |
||
| 244 | * |
||
| 245 | * @return \eZ\Publish\API\Repository\Values\Content\Search\SearchResult |
||
| 246 | */ |
||
| 247 | protected function searchSubGroups(Location $location, $offset = 0, $limit = 25) |
||
| 263 | |||
| 264 | /** |
||
| 265 | * Removes a user group. |
||
| 266 | * |
||
| 267 | * the users which are not assigned to other groups will be deleted. |
||
| 268 | * |
||
| 269 | * @param \eZ\Publish\API\Repository\Values\User\UserGroup $userGroup |
||
| 270 | * |
||
| 271 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to create a user group |
||
| 272 | */ |
||
| 273 | public function deleteUserGroup(APIUserGroup $userGroup) |
||
| 289 | |||
| 290 | /** |
||
| 291 | * Moves the user group to another parent. |
||
| 292 | * |
||
| 293 | * @param \eZ\Publish\API\Repository\Values\User\UserGroup $userGroup |
||
| 294 | * @param \eZ\Publish\API\Repository\Values\User\UserGroup $newParent |
||
| 295 | * |
||
| 296 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to move the user group |
||
| 297 | */ |
||
| 298 | public function moveUserGroup(APIUserGroup $userGroup, APIUserGroup $newParent) |
||
| 329 | |||
| 330 | /** |
||
| 331 | * Updates the group profile with fields and meta data. |
||
| 332 | * |
||
| 333 | * 4.x: If the versionUpdateStruct is set in $userGroupUpdateStruct, this method internally creates a content draft, updates ts with the provided data |
||
| 334 | * and publishes the draft. If a draft is explicitly required, the user group can be updated via the content service methods. |
||
| 335 | * |
||
| 336 | * @param \eZ\Publish\API\Repository\Values\User\UserGroup $userGroup |
||
| 337 | * @param \eZ\Publish\API\Repository\Values\User\UserGroupUpdateStruct $userGroupUpdateStruct |
||
| 338 | * |
||
| 339 | * @return \eZ\Publish\API\Repository\Values\User\UserGroup |
||
| 340 | * |
||
| 341 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to update the user group |
||
| 342 | * @throws \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException if a field in the $userGroupUpdateStruct is not valid |
||
| 343 | * @throws \eZ\Publish\API\Repository\Exceptions\ContentValidationException if a required field is set empty |
||
| 344 | */ |
||
| 345 | public function updateUserGroup(APIUserGroup $userGroup, UserGroupUpdateStruct $userGroupUpdateStruct) |
||
| 386 | |||
| 387 | /** |
||
| 388 | * Create a new user. The created user is published by this method. |
||
| 389 | * |
||
| 390 | * @param \eZ\Publish\API\Repository\Values\User\UserCreateStruct $userCreateStruct the data used for creating the user |
||
| 391 | * @param \eZ\Publish\API\Repository\Values\User\UserGroup[] $parentGroups the groups which are assigned to the user after creation |
||
| 392 | * |
||
| 393 | * @return \eZ\Publish\API\Repository\Values\User\User |
||
| 394 | * |
||
| 395 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to move the user group |
||
| 396 | * @throws \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException if a field in the $userCreateStruct is not valid |
||
| 397 | * @throws \eZ\Publish\API\Repository\Exceptions\ContentValidationException if a required field is missing or set to an empty value |
||
| 398 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if a user with provided login already exists |
||
| 399 | */ |
||
| 400 | public function createUser(APIUserCreateStruct $userCreateStruct, array $parentGroups) |
||
| 401 | { |
||
| 402 | $contentService = $this->repository->getContentService(); |
||
| 403 | $locationService = $this->repository->getLocationService(); |
||
| 404 | |||
| 405 | $locationCreateStructs = []; |
||
| 406 | foreach ($parentGroups as $parentGroup) { |
||
| 407 | $parentGroup = $this->loadUserGroup($parentGroup->id); |
||
| 408 | if ($parentGroup->getVersionInfo()->getContentInfo()->mainLocationId !== null) { |
||
| 409 | $locationCreateStructs[] = $locationService->newLocationCreateStruct( |
||
| 410 | $parentGroup->getVersionInfo()->getContentInfo()->mainLocationId |
||
| 411 | ); |
||
| 412 | } |
||
| 413 | } |
||
| 414 | |||
| 415 | // Search for the first ezuser field type in content type |
||
| 416 | $userFieldDefinition = $this->getUserFieldDefinition($userCreateStruct->contentType); |
||
| 417 | if ($userFieldDefinition === null) { |
||
| 418 | throw new ContentValidationException('the provided Content Type does not contain the ezuser Field Type'); |
||
| 419 | } |
||
| 420 | |||
| 421 | $this->repository->beginTransaction(); |
||
| 422 | try { |
||
| 423 | $contentDraft = $contentService->createContent($userCreateStruct, $locationCreateStructs); |
||
| 424 | // There is no need to create user separately, just load it from SPI |
||
| 425 | $spiUser = $this->userHandler->load($contentDraft->id); |
||
| 426 | $publishedContent = $contentService->publishVersion($contentDraft->getVersionInfo()); |
||
| 427 | |||
| 428 | // User\Handler::create call is currently used to clear cache only |
||
| 429 | $this->userHandler->create( |
||
| 430 | new SPIUser( |
||
| 431 | [ |
||
| 432 | 'id' => $spiUser->id, |
||
| 433 | 'login' => $spiUser->login, |
||
| 434 | 'email' => $spiUser->email, |
||
| 435 | ] |
||
| 436 | ) |
||
| 437 | ); |
||
| 438 | |||
| 439 | $this->repository->commit(); |
||
| 440 | } catch (Exception $e) { |
||
| 441 | $this->repository->rollback(); |
||
| 442 | throw $e; |
||
| 443 | } |
||
| 444 | |||
| 445 | return $this->buildDomainUserObject($spiUser, $publishedContent); |
||
| 446 | } |
||
| 447 | |||
| 448 | /** |
||
| 449 | * Loads a user. |
||
| 450 | * |
||
| 451 | * @param mixed $userId |
||
| 452 | * @param string[] $prioritizedLanguages Used as prioritized language code on translated properties of returned object. |
||
| 453 | * |
||
| 454 | * @return \eZ\Publish\API\Repository\Values\User\User |
||
| 455 | * |
||
| 456 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException if a user with the given id was not found |
||
| 457 | */ |
||
| 458 | public function loadUser($userId, array $prioritizedLanguages = []) |
||
| 459 | { |
||
| 460 | /** @var \eZ\Publish\API\Repository\Values\Content\Content $content */ |
||
| 461 | $content = $this->repository->getContentService()->internalLoadContentById($userId, $prioritizedLanguages); |
||
| 462 | // Get spiUser value from Field Value |
||
| 463 | foreach ($content->getFields() as $field) { |
||
| 464 | if (!$field->value instanceof UserValue) { |
||
| 465 | continue; |
||
| 466 | } |
||
| 467 | |||
| 468 | /** @var \eZ\Publish\Core\FieldType\User\Value $value */ |
||
| 469 | $value = $field->value; |
||
| 470 | $spiUser = new SPIUser(); |
||
| 471 | $spiUser->id = $value->contentId; |
||
| 472 | $spiUser->login = $value->login; |
||
| 473 | $spiUser->email = $value->email; |
||
| 474 | $spiUser->hashAlgorithm = $value->passwordHashType; |
||
| 475 | $spiUser->passwordHash = $value->passwordHash; |
||
| 476 | $spiUser->passwordUpdatedAt = $value->passwordUpdatedAt ? $value->passwordUpdatedAt->getTimestamp() : null; |
||
| 477 | $spiUser->isEnabled = $value->enabled; |
||
| 478 | $spiUser->maxLogin = $value->maxLogin; |
||
| 479 | break; |
||
| 480 | } |
||
| 481 | |||
| 482 | // If for some reason not found, load it |
||
| 483 | if (!isset($spiUser)) { |
||
| 484 | $spiUser = $this->userHandler->load($userId); |
||
| 485 | } |
||
| 486 | |||
| 487 | return $this->buildDomainUserObject($spiUser, $content); |
||
| 488 | } |
||
| 489 | |||
| 490 | /** |
||
| 491 | * Checks if credentials are valid for provided User. |
||
| 492 | * |
||
| 493 | * @param \eZ\Publish\API\Repository\Values\User\User $user |
||
| 494 | * @param string $credentials |
||
| 495 | * |
||
| 496 | * @return bool |
||
| 497 | */ |
||
| 498 | public function checkUserCredentials(APIUser $user, string $credentials): bool |
||
| 499 | { |
||
| 500 | return $this->comparePasswordHashForAPIUser($user, $credentials); |
||
| 501 | } |
||
| 502 | |||
| 503 | /** |
||
| 504 | * Update password hash to the type configured for the service, if they differ. |
||
| 505 | * |
||
| 506 | * @param string $login User login |
||
| 507 | * @param string $password User password |
||
| 508 | * @param \eZ\Publish\SPI\Persistence\User $spiUser |
||
| 509 | * |
||
| 510 | * @throws \eZ\Publish\Core\Base\Exceptions\BadStateException if the password is not correctly saved, in which case the update is reverted |
||
| 511 | */ |
||
| 512 | private function updatePasswordHash($login, $password, SPIUser $spiUser) |
||
| 513 | { |
||
| 514 | $hashType = $this->passwordHashService->getDefaultHashType(); |
||
| 515 | if ($spiUser->hashAlgorithm === $hashType) { |
||
| 516 | return; |
||
| 517 | } |
||
| 518 | |||
| 519 | $spiUser->passwordHash = $this->passwordHashService->createPasswordHash($password, $hashType); |
||
| 520 | $spiUser->hashAlgorithm = $hashType; |
||
| 521 | |||
| 522 | $this->repository->beginTransaction(); |
||
| 523 | $this->userHandler->update($spiUser); |
||
| 524 | $reloadedSpiUser = $this->userHandler->load($spiUser->id); |
||
| 525 | |||
| 526 | if ($reloadedSpiUser->passwordHash === $spiUser->passwordHash) { |
||
| 527 | $this->repository->commit(); |
||
| 528 | } else { |
||
| 529 | // Password hash was not correctly saved, possible cause: EZP-28692 |
||
| 530 | $this->repository->rollback(); |
||
| 531 | if (isset($this->logger)) { |
||
| 532 | $this->logger->critical('Password hash could not be updated. Please verify that your database schema is up to date.'); |
||
| 533 | } |
||
| 534 | |||
| 535 | throw new BadStateException( |
||
| 536 | 'user', |
||
| 537 | 'Could not save updated password hash, reverting to previous hash. Please verify that your database schema is up to date.' |
||
| 538 | ); |
||
| 539 | } |
||
| 540 | } |
||
| 541 | |||
| 542 | /** |
||
| 543 | * Loads a user for the given login. |
||
| 544 | * |
||
| 545 | * {@inheritdoc} |
||
| 546 | * |
||
| 547 | * @param string $login |
||
| 548 | * @param string[] $prioritizedLanguages Used as prioritized language code on translated properties of returned object. |
||
| 549 | * |
||
| 550 | * @return \eZ\Publish\API\Repository\Values\User\User |
||
| 551 | * |
||
| 552 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException if a user with the given credentials was not found |
||
| 553 | */ |
||
| 554 | public function loadUserByLogin($login, array $prioritizedLanguages = []) |
||
| 555 | { |
||
| 556 | if (!is_string($login) || empty($login)) { |
||
| 557 | throw new InvalidArgumentValue('login', $login); |
||
| 558 | } |
||
| 559 | |||
| 560 | $spiUser = $this->userHandler->loadByLogin($login); |
||
| 561 | |||
| 562 | return $this->buildDomainUserObject($spiUser, null, $prioritizedLanguages); |
||
| 563 | } |
||
| 564 | |||
| 565 | /** |
||
| 566 | * Loads a user for the given email. |
||
| 567 | * |
||
| 568 | * {@inheritdoc} |
||
| 569 | * |
||
| 570 | * @param string $email |
||
| 571 | * @param string[] $prioritizedLanguages Used as prioritized language code on translated properties of returned object. |
||
| 572 | * |
||
| 573 | * @return \eZ\Publish\API\Repository\Values\User\User |
||
| 574 | * |
||
| 575 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
||
| 576 | */ |
||
| 577 | public function loadUserByEmail(string $email, array $prioritizedLanguages = []): APIUser |
||
| 578 | { |
||
| 579 | if (empty($email)) { |
||
| 580 | throw new InvalidArgumentValue('email', $email); |
||
| 581 | } |
||
| 582 | |||
| 583 | $spiUser = $this->userHandler->loadByEmail($email); |
||
| 584 | |||
| 585 | return $this->buildDomainUserObject($spiUser, null, $prioritizedLanguages); |
||
| 586 | } |
||
| 587 | |||
| 588 | /** |
||
| 589 | * Loads a user for the given email. |
||
| 590 | * |
||
| 591 | * {@inheritdoc} |
||
| 592 | * |
||
| 593 | * @param string $email |
||
| 594 | * @param string[] $prioritizedLanguages Used as prioritized language code on translated properties of returned object. |
||
| 595 | * |
||
| 596 | * @return \eZ\Publish\API\Repository\Values\User\User[] |
||
| 597 | * |
||
| 598 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
||
| 599 | */ |
||
| 600 | public function loadUsersByEmail(string $email, array $prioritizedLanguages = []): array |
||
| 601 | { |
||
| 602 | if (empty($email)) { |
||
| 603 | throw new InvalidArgumentValue('email', $email); |
||
| 604 | } |
||
| 605 | |||
| 606 | $users = []; |
||
| 607 | foreach ($this->userHandler->loadUsersByEmail($email) as $spiUser) { |
||
| 608 | $users[] = $this->buildDomainUserObject($spiUser, null, $prioritizedLanguages); |
||
| 609 | } |
||
| 610 | |||
| 611 | return $users; |
||
| 612 | } |
||
| 613 | |||
| 614 | /** |
||
| 615 | * Loads a user for the given token. |
||
| 616 | * |
||
| 617 | * {@inheritdoc} |
||
| 618 | * |
||
| 619 | * @param string $hash |
||
| 620 | * @param string[] $prioritizedLanguages Used as prioritized language code on translated properties of returned object. |
||
| 621 | * |
||
| 622 | * @return \eZ\Publish\API\Repository\Values\User\User |
||
| 623 | * |
||
| 624 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException |
||
| 625 | * @throws \eZ\Publish\Core\Base\Exceptions\InvalidArgumentValue |
||
| 626 | */ |
||
| 627 | public function loadUserByToken($hash, array $prioritizedLanguages = []) |
||
| 637 | |||
| 638 | /** |
||
| 639 | * This method deletes a user. |
||
| 640 | * |
||
| 641 | * @param \eZ\Publish\API\Repository\Values\User\User $user |
||
| 642 | * |
||
| 643 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to delete the user |
||
| 644 | */ |
||
| 645 | public function deleteUser(APIUser $user) |
||
| 663 | |||
| 664 | /** |
||
| 665 | * Updates a user. |
||
| 666 | * |
||
| 667 | * 4.x: If the versionUpdateStruct is set in the user update structure, this method internally creates a content draft, updates ts with the provided data |
||
| 668 | * and publishes the draft. If a draft is explicitly required, the user group can be updated via the content service methods. |
||
| 669 | * |
||
| 670 | * @param \eZ\Publish\API\Repository\Values\User\User $user |
||
| 671 | * @param \eZ\Publish\API\Repository\Values\User\UserUpdateStruct $userUpdateStruct |
||
| 672 | * |
||
| 673 | * @throws \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException if a field in the $userUpdateStruct is not valid |
||
| 674 | * @throws \eZ\Publish\API\Repository\Exceptions\ContentValidationException if a required field is set empty |
||
| 675 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to update the user |
||
| 676 | * |
||
| 677 | * @return \eZ\Publish\API\Repository\Values\User\User |
||
| 678 | */ |
||
| 679 | public function updateUser(APIUser $user, UserUpdateStruct $userUpdateStruct) |
||
| 775 | |||
| 776 | /** |
||
| 777 | * Update the user token information specified by the user token struct. |
||
| 778 | * |
||
| 779 | * @param \eZ\Publish\API\Repository\Values\User\User $user |
||
| 780 | * @param \eZ\Publish\API\Repository\Values\User\UserTokenUpdateStruct $userTokenUpdateStruct |
||
| 781 | * |
||
| 782 | * @throws \eZ\Publish\Core\Base\Exceptions\InvalidArgumentValue |
||
| 783 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException |
||
| 784 | * @throws \RuntimeException |
||
| 785 | * @throws \Exception |
||
| 786 | * |
||
| 787 | * @return \eZ\Publish\API\Repository\Values\User\User |
||
| 788 | */ |
||
| 789 | public function updateUserToken(APIUser $user, UserTokenUpdateStruct $userTokenUpdateStruct) |
||
| 820 | |||
| 821 | /** |
||
| 822 | * Expires user token with user hash. |
||
| 823 | * |
||
| 824 | * @param string $hash |
||
| 825 | */ |
||
| 826 | public function expireUserToken($hash) |
||
| 837 | |||
| 838 | /** |
||
| 839 | * Assigns a new user group to the user. |
||
| 840 | * |
||
| 841 | * @param \eZ\Publish\API\Repository\Values\User\User $user |
||
| 842 | * @param \eZ\Publish\API\Repository\Values\User\UserGroup $userGroup |
||
| 843 | * |
||
| 844 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to assign the user group to the user |
||
| 845 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if the user is already in the given user group |
||
| 846 | */ |
||
| 847 | public function assignUserToUserGroup(APIUser $user, APIUserGroup $userGroup) |
||
| 884 | |||
| 885 | /** |
||
| 886 | * Removes a user group from the user. |
||
| 887 | * |
||
| 888 | * @param \eZ\Publish\API\Repository\Values\User\User $user |
||
| 889 | * @param \eZ\Publish\API\Repository\Values\User\UserGroup $userGroup |
||
| 890 | * |
||
| 891 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to remove the user group from the user |
||
| 892 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if the user is not in the given user group |
||
| 893 | * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException If $userGroup is the last assigned user group |
||
| 894 | */ |
||
| 895 | public function unAssignUserFromUserGroup(APIUser $user, APIUserGroup $userGroup) |
||
| 932 | |||
| 933 | /** |
||
| 934 | * Loads the user groups the user belongs to. |
||
| 935 | * |
||
| 936 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed read the user or user group |
||
| 937 | * |
||
| 938 | * @param \eZ\Publish\API\Repository\Values\User\User $user |
||
| 939 | * @param int $offset the start offset for paging |
||
| 940 | * @param int $limit the number of user groups returned |
||
| 941 | * @param string[] $prioritizedLanguages Used as prioritized language code on translated properties of returned object. |
||
| 942 | * |
||
| 943 | * @return \eZ\Publish\API\Repository\Values\User\UserGroup[] |
||
| 944 | */ |
||
| 945 | public function loadUserGroupsOfUser(APIUser $user, $offset = 0, $limit = 25, array $prioritizedLanguages = []) |
||
| 991 | |||
| 992 | /** |
||
| 993 | * Loads the users of a user group. |
||
| 994 | * |
||
| 995 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to read the users or user group |
||
| 996 | * |
||
| 997 | * @param \eZ\Publish\API\Repository\Values\User\UserGroup $userGroup |
||
| 998 | * @param int $offset the start offset for paging |
||
| 999 | * @param int $limit the number of users returned |
||
| 1000 | * @param string[] $prioritizedLanguages Used as prioritized language code on translated properties of returned object. |
||
| 1001 | * |
||
| 1002 | * @return \eZ\Publish\API\Repository\Values\User\User[] |
||
| 1003 | */ |
||
| 1004 | public function loadUsersOfUserGroup( |
||
| 1049 | |||
| 1050 | /** |
||
| 1051 | * {@inheritdoc} |
||
| 1052 | */ |
||
| 1053 | public function isUser(APIContent $content): bool |
||
| 1070 | |||
| 1071 | /** |
||
| 1072 | * {@inheritdoc} |
||
| 1073 | */ |
||
| 1074 | public function isUserGroup(APIContent $content): bool |
||
| 1078 | |||
| 1079 | /** |
||
| 1080 | * Instantiate a user create class. |
||
| 1081 | * |
||
| 1082 | * @param string $login the login of the new user |
||
| 1083 | * @param string $email the email of the new user |
||
| 1084 | * @param string $password the plain password of the new user |
||
| 1085 | * @param string $mainLanguageCode the main language for the underlying content object |
||
| 1086 | * @param \eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType 5.x the content type for the underlying content object. In 4.x it is ignored and taken from the configuration |
||
| 1087 | * |
||
| 1088 | * @return \eZ\Publish\API\Repository\Values\User\UserCreateStruct |
||
| 1089 | */ |
||
| 1090 | public function newUserCreateStruct($login, $email, $password, $mainLanguageCode, $contentType = null) |
||
| 1131 | |||
| 1132 | /** |
||
| 1133 | * Instantiate a user group create class. |
||
| 1134 | * |
||
| 1135 | * @param string $mainLanguageCode The main language for the underlying content object |
||
| 1136 | * @param null|\eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType 5.x the content type for the underlying content object. In 4.x it is ignored and taken from the configuration |
||
| 1137 | * |
||
| 1138 | * @return \eZ\Publish\API\Repository\Values\User\UserGroupCreateStruct |
||
| 1139 | */ |
||
| 1140 | public function newUserGroupCreateStruct($mainLanguageCode, $contentType = null) |
||
| 1156 | |||
| 1157 | /** |
||
| 1158 | * Instantiate a new user update struct. |
||
| 1159 | * |
||
| 1160 | * @return \eZ\Publish\API\Repository\Values\User\UserUpdateStruct |
||
| 1161 | */ |
||
| 1162 | public function newUserUpdateStruct() |
||
| 1166 | |||
| 1167 | /** |
||
| 1168 | * Instantiate a new user group update struct. |
||
| 1169 | * |
||
| 1170 | * @return \eZ\Publish\API\Repository\Values\User\UserGroupUpdateStruct |
||
| 1171 | */ |
||
| 1172 | public function newUserGroupUpdateStruct() |
||
| 1176 | |||
| 1177 | /** |
||
| 1178 | * {@inheritdoc} |
||
| 1179 | */ |
||
| 1180 | public function validatePassword(string $password, PasswordValidationContext $context = null): array |
||
| 1218 | |||
| 1219 | /** |
||
| 1220 | * Builds the domain UserGroup object from provided Content object. |
||
| 1221 | * |
||
| 1222 | * @param \eZ\Publish\API\Repository\Values\Content\Content $content |
||
| 1223 | * |
||
| 1224 | * @return \eZ\Publish\API\Repository\Values\User\UserGroup |
||
| 1225 | */ |
||
| 1226 | protected function buildDomainUserGroupObject(APIContent $content) |
||
| 1244 | |||
| 1245 | /** |
||
| 1246 | * Builds the domain user object from provided persistence user object. |
||
| 1247 | * |
||
| 1248 | * @param \eZ\Publish\SPI\Persistence\User $spiUser |
||
| 1249 | * @param \eZ\Publish\API\Repository\Values\Content\Content|null $content |
||
| 1250 | * @param string[] $prioritizedLanguages Used as prioritized language code on translated properties of returned object. |
||
| 1251 | * |
||
| 1252 | * @return \eZ\Publish\API\Repository\Values\User\User |
||
| 1253 | */ |
||
| 1254 | protected function buildDomainUserObject( |
||
| 1279 | |||
| 1280 | public function getPasswordInfo(APIUser $user): PasswordInfo |
||
| 1311 | |||
| 1312 | private function getUserFieldDefinition(ContentType $contentType): ?FieldDefinition |
||
| 1316 | |||
| 1317 | /** |
||
| 1318 | * Verifies if the provided login and password are valid for eZ\Publish\SPI\Persistence\User. |
||
| 1319 | * |
||
| 1320 | * @return bool return true if the login and password are sucessfully validated and false, if not. |
||
| 1321 | */ |
||
| 1322 | protected function comparePasswordHashForSPIUser(SPIUser $user, string $password): bool |
||
| 1323 | { |
||
| 1326 | |||
| 1327 | /** |
||
| 1328 | * Verifies if the provided login and password are valid for eZ\Publish\API\Repository\Values\User\User. |
||
| 1329 | * |
||
| 1330 | * @return bool return true if the login and password are sucessfully validated and false, if not. |
||
| 1331 | */ |
||
| 1332 | protected function comparePasswordHashForAPIUser(APIUser $user, string $password): bool |
||
| 1336 | |||
| 1337 | /** |
||
| 1338 | * Verifies if the provided login and password are valid against given password hash and hash type. |
||
| 1339 | * |
||
| 1340 | * @param string $plainPassword User password |
||
| 1341 | * @param string $passwordHash User password hash |
||
| 1342 | * @param int $hashAlgorithm Hash type |
||
| 1343 | * |
||
| 1344 | * @return bool return true if the login and password are sucessfully validated and false, if not. |
||
| 1345 | */ |
||
| 1346 | private function comparePasswordHashes( |
||
| 1353 | |||
| 1354 | /** |
||
| 1355 | * Return true if any of the UserUpdateStruct properties refers to User Profile (Content) update. |
||
| 1356 | * |
||
| 1357 | * @param UserUpdateStruct $userUpdateStruct |
||
| 1358 | * |
||
| 1359 | * @return bool |
||
| 1360 | */ |
||
| 1361 | private function isUserProfileUpdateRequested(UserUpdateStruct $userUpdateStruct) |
||
| 1370 | |||
| 1371 | private function getDateTime(?int $timestamp): ?DateTimeInterface |
||
| 1383 | } |
||
| 1384 |
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.