Skip to content

Commit f88a02b

Browse files
committed
Switch events to use asymetric visibility
1 parent 555e55a commit f88a02b

21 files changed

Lines changed: 39 additions & 168 deletions

bundle/Controller/User/Activate.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function __invoke(string $hash): Response
6464

6565
$preActivateEvent = new UserEvents\PreActivateEvent($user, $userUpdateStruct);
6666
$this->eventDispatcher->dispatch($preActivateEvent, SiteEvents::USER_PRE_ACTIVATE);
67-
$userUpdateStruct = $preActivateEvent->getUserUpdateStruct();
67+
$userUpdateStruct = $preActivateEvent->userUpdateStruct;
6868

6969
$user = $this->repository->sudo(
7070
static fn (Repository $repository): User => $repository->getUserService()->updateUser($user, $userUpdateStruct),

bundle/Controller/User/Register.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public function __invoke(Request $request): Response
109109
$preUserRegisterEvent->setParameter('form', $form);
110110

111111
$this->eventDispatcher->dispatch($preUserRegisterEvent, SiteEvents::USER_PRE_REGISTER);
112-
$data->payload = $preUserRegisterEvent->getUserCreateStruct();
112+
$data->payload = $preUserRegisterEvent->userCreateStruct;
113113

114114
foreach ($data->payload->fields as $field) {
115115
if ($field->fieldTypeIdentifier !== 'ibexa_user') {

bundle/Controller/User/ResetPassword.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function __invoke(Request $request, string $hash): Response
8585
$prePasswordResetEvent->setParameter('form', $form);
8686

8787
$this->eventDispatcher->dispatch($prePasswordResetEvent, SiteEvents::USER_PRE_PASSWORD_RESET);
88-
$userUpdateStruct = $prePasswordResetEvent->getUserUpdateStruct();
88+
$userUpdateStruct = $prePasswordResetEvent->userUpdateStruct;
8989

9090
$user = $this->repository->sudo(
9191
static fn (Repository $repository): User => $repository->getUserService()->updateUser($user, $userUpdateStruct),

bundle/Core/EventListener/CreateUserListener.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,8 @@ public static function getSubscribedEvents(): array
2121

2222
public function onCreateUser(CreateUserEvent $event): void
2323
{
24-
$user = $event->getUser();
25-
26-
if ($user->enabled) {
27-
$this->ngUserSettingRepository->activateUser($user->id);
24+
if ($event->user->enabled) {
25+
$this->ngUserSettingRepository->activateUser($event->user->id);
2826
}
2927
}
3028
}

bundle/Event/Content/DownloadEvent.php

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -10,41 +10,9 @@
1010
final class DownloadEvent extends Event
1111
{
1212
public function __construct(
13-
private int $contentId,
14-
private int $fieldId,
15-
private int $versionNo,
16-
private BinaryStreamResponse $response,
13+
public private(set) int $contentId,
14+
public private(set) int $fieldId,
15+
public private(set) int $versionNo,
16+
public private(set) BinaryStreamResponse $response,
1717
) {}
18-
19-
/**
20-
* Get field ID.
21-
*/
22-
public function getFieldId(): int
23-
{
24-
return $this->fieldId;
25-
}
26-
27-
/**
28-
* Returns content ID.
29-
*/
30-
public function getContentId(): int
31-
{
32-
return $this->contentId;
33-
}
34-
35-
/**
36-
* Returns version number.
37-
*/
38-
public function getVersionNo(): int
39-
{
40-
return $this->versionNo;
41-
}
42-
43-
/**
44-
* Returns the response.
45-
*/
46-
public function getResponse(): BinaryStreamResponse
47-
{
48-
return $this->response;
49-
}
5018
}

bundle/Event/Menu/LocationMenuItemEvent.php

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,13 @@
1414
final class LocationMenuItemEvent extends Event
1515
{
1616
public function __construct(
17-
private ItemInterface $item,
18-
private Location $location,
17+
/**
18+
* Returns the item which was built.
19+
*/
20+
public private(set) ItemInterface $item,
21+
/**
22+
* Returns the Ibexa location for which the menu item was built.
23+
*/
24+
public private(set) Location $location,
1925
) {}
20-
21-
/**
22-
* Returns the item which was built.
23-
*/
24-
public function getItem(): ItemInterface
25-
{
26-
return $this->item;
27-
}
28-
29-
/**
30-
* Returns the Ibexa location for which the menu item was built.
31-
*/
32-
public function getLocation(): Location
33-
{
34-
return $this->location;
35-
}
3626
}

bundle/Event/User/ActivationRequestEvent.php

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,7 @@
99
final class ActivationRequestEvent extends UserEvent
1010
{
1111
public function __construct(
12-
private string $email,
13-
private ?User $user = null,
12+
public private(set) string $email,
13+
public private(set) ?User $user = null,
1414
) {}
15-
16-
public function getEmail(): string
17-
{
18-
return $this->email;
19-
}
20-
21-
public function getUser(): ?User
22-
{
23-
return $this->user;
24-
}
2515
}

bundle/Event/User/PasswordResetRequestEvent.php

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,7 @@
99
final class PasswordResetRequestEvent extends UserEvent
1010
{
1111
public function __construct(
12-
private string $email,
13-
private ?User $user = null,
12+
public private(set) string $email,
13+
public private(set) ?User $user = null,
1414
) {}
15-
16-
public function getEmail(): string
17-
{
18-
return $this->email;
19-
}
20-
21-
public function getUser(): ?User
22-
{
23-
return $this->user;
24-
}
2515
}

bundle/Event/User/PostActivateEvent.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@
99
final class PostActivateEvent extends UserEvent
1010
{
1111
public function __construct(
12-
private User $user,
12+
public private(set) User $user,
1313
) {}
14-
15-
public function getUser(): User
16-
{
17-
return $this->user;
18-
}
1914
}

bundle/Event/User/PostPasswordResetEvent.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@
99
final class PostPasswordResetEvent extends UserEvent
1010
{
1111
public function __construct(
12-
private User $user,
12+
public private(set) User $user,
1313
) {}
14-
15-
public function getUser(): User
16-
{
17-
return $this->user;
18-
}
1914
}

0 commit comments

Comments
 (0)