Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IBX-5817: Exposed UserService::getUserContentTypeIdentifiers public API #238

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/contracts/Repository/Decorator/UserServiceDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,11 @@ public function getPasswordInfo(User $user): PasswordInfo
{
return $this->innerService->getPasswordInfo($user);
}

public function getUserContentTypeIdentifiers(): array
{
return $this->innerService->getUserContentTypeIdentifiers();
}
}

class_alias(UserServiceDecorator::class, 'eZ\Publish\SPI\Repository\Decorator\UserServiceDecorator');
7 changes: 7 additions & 0 deletions src/contracts/Repository/UserService.php
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,13 @@ public function validatePassword(string $password, PasswordValidationContext $co
* @return \Ibexa\Contracts\Core\Repository\Values\User\PasswordInfo
*/
public function getPasswordInfo(User $user): PasswordInfo;

/**
* Returns configured list of User Content Type identifiers.
*
* @return array<string>
*/
public function getUserContentTypeIdentifiers(): array;
}

class_alias(UserService::class, 'eZ\Publish\API\Repository\UserService');
5 changes: 5 additions & 0 deletions src/lib/Repository/SiteAccessAware/UserService.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,11 @@ public function getPasswordInfo(User $user): PasswordInfo
{
return $this->service->getPasswordInfo($user);
}

public function getUserContentTypeIdentifiers(): array
{
return $this->service->getUserContentTypeIdentifiers();
}
}

class_alias(UserService::class, 'eZ\Publish\Core\Repository\SiteAccessAware\UserService');
5 changes: 1 addition & 4 deletions src/lib/Repository/UserService.php
Original file line number Diff line number Diff line change
Expand Up @@ -1394,10 +1394,7 @@ private function getDateTime(?int $timestamp): ?DateTimeInterface
return null;
}

/**
* @return string[]
*/
private function getUserContentTypeIdentifiers(): array
public function getUserContentTypeIdentifiers(): array
{
return $this->configResolver->getParameter('user_content_type_identifier');
}
Expand Down
6 changes: 6 additions & 0 deletions tests/integration/Core/Repository/UserServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3265,6 +3265,12 @@ public function testGetPasswordInfoIfExpirationWarningIsDisabled(): void
$this->assertEquals(new PasswordInfo($expectedPasswordExpirationDate, null), $passwordInfo);
}

public function testGetUserContentTypeIdentifiers(): void
{
$userService = $this->getRepository()->getUserService();
self::assertEquals(['user'], $userService->getUserContentTypeIdentifiers());
}

public function createTestUser(ContentType $contentType): User
{
return $this->createTestUserWithPassword(self::EXAMPLE_PASSWORD, $contentType);
Expand Down
2 changes: 2 additions & 0 deletions tests/lib/Repository/SiteAccessAware/UserServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ public function providerForPassTroughMethods()
['checkUserCredentials', [$user, 'H@xi0r!']],
['validatePassword', ['H@xi0r!', $passwordValidationContext], []],
['getPasswordInfo', [$user], new PasswordInfo()],

['getUserContentTypeIdentifiers', [], ['user']],
];
}

Expand Down