Exponential 5.x Kernel 7.5.40 Exponential New Stack (Symfony-based) Kernel — PHP Class Reference

User/ParameterProvider.php
Go to the documentation of this file.
1 <?php
2
7 declare(strict_types=1);
8
9 namespace eZ\Publish\Core\MVC\Symfony\FieldType\User;
10
11 use DateTime;
12 use eZ\Publish\API\Repository\UserService;
13 use eZ\Publish\API\Repository\Values\Content\Field;
14 use eZ\Publish\Core\MVC\Symfony\FieldType\View\ParameterProviderInterface;
15
16 class ParameterProvider implements ParameterProviderInterface
17 {
19 private $userService;
20
21 public function __construct(UserService $userService)
22 {
23 $this->userService = $userService;
24 }
25
26 public function getViewParameters(Field $field): array
27 {
28 $passwordInfo = $this->userService->getPasswordInfo(
29 $this->userService->loadUser($field->value->contentId)
30 );
31
32 $passwordExpiresIn = null;
33 if (!$passwordInfo->isPasswordExpired() && $passwordInfo->hasExpirationDate()) {
34 $passwordExpiresIn = $passwordInfo->getExpirationDate()->diff(new DateTime());
35 }
36
37 return [
38 'is_password_expired' => $passwordInfo->isPasswordExpired(),
39 'password_expires_at' => $passwordInfo->getExpirationDate(),
40 'password_expires_in' => $passwordExpiresIn,
41 ];
42 }
43 }
eZ\Publish\API\Repository\Values\Content\Field
Definition: API/Repository/Values/Content/Field.php:21
eZ\Publish\Core\MVC\Symfony\FieldType\User\ParameterProvider
Definition: User/ParameterProvider.php:17
eZ\Publish\Core\MVC\Symfony\FieldType\User\ParameterProvider\getViewParameters
getViewParameters(Field $field)
Returns a hash of parameters to inject to the associated fieldtype's view template.
Definition: User/ParameterProvider.php:26
eZ\Publish\Core\MVC\Symfony\FieldType\User\ParameterProvider\__construct
__construct(UserService $userService)
Definition: User/ParameterProvider.php:21
eZ\Publish\Core\MVC\Symfony\FieldType\User\ParameterProvider\$userService
$userService
Definition: User/ParameterProvider.php:19
eZ\Publish\API\Repository\UserService
Definition: API/Repository/UserService.php:26
eZ\Publish\Core\MVC\Symfony\FieldType\View\ParameterProviderInterface
Interface for services providing additional parameters to a fieldtype's view template (using ez_rende...
Definition: ParameterProviderInterface.php:18
eZ\Publish\Core\MVC\Symfony\FieldType\User
Definition: User/ParameterProvider.php:9
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.