44
55namespace App \AdminModule \Components ;
66
7+ use App \AdminModule \Presenters \AdminBasePresenter ;
78use App \Model \Application \Application ;
89use App \Model \Application \Repositories \ApplicationRepository ;
910use App \Model \Application \RolesApplication ;
3233use Ublaboo \DataGrid \DataGrid ;
3334use Ublaboo \DataGrid \Exception \DataGridException ;
3435
36+ use function assert ;
37+
3538/**
3639 * Komponenta pro správu přihlášek.
3740 */
@@ -211,6 +214,7 @@ public function add(stdClass $values): void
211214 $ selectedSubevents = $ this ->subeventRepository ->findSubeventsByIds ($ values ->subevents );
212215
213216 $ p = $ this ->getPresenter ();
217+ assert ($ p instanceof AdminBasePresenter);
214218
215219 if (! $ this ->validators ->validateSubeventsCapacities ($ selectedSubevents , $ this ->user )) {
216220 $ p ->flashMessage ('admin.users.users_applications_subevents_occupied ' , 'danger ' );
@@ -226,9 +230,7 @@ public function add(stdClass $values): void
226230 return ;
227231 }
228232
229- $ loggedUser = $ this ->userRepository ->findById ($ this ->getPresenter ()->user ->id );
230-
231- $ this ->applicationService ->addSubeventsApplication ($ this ->user , $ selectedSubevents , $ loggedUser );
233+ $ this ->applicationService ->addSubeventsApplication ($ this ->user , $ selectedSubevents , $ p ->getDbUser ());
232234
233235 $ p ->flashMessage ('admin.users.users_applications_saved ' , 'success ' );
234236 $ p ->redrawControl ('flashes ' );
@@ -246,6 +248,7 @@ public function edit(string $id, stdClass $values): void
246248 $ selectedSubevents = $ this ->subeventRepository ->findSubeventsByIds ($ values ->subevents );
247249
248250 $ p = $ this ->getPresenter ();
251+ assert ($ p instanceof AdminBasePresenter);
249252
250253 if ($ application instanceof RolesApplication) {
251254 if (! $ selectedSubevents ->isEmpty ()) {
@@ -277,7 +280,7 @@ public function edit(string $id, stdClass $values): void
277280 return ;
278281 }
279282
280- $ loggedUser = $ this -> userRepository -> findById ( $ this -> getPresenter ()-> user -> id );
283+ $ loggedUser = $ p -> getDbUser ( );
281284
282285 $ this ->em ->wrapInTransaction (function () use ($ application , $ selectedSubevents , $ values , $ loggedUser ): void {
283286 if ($ application instanceof SubeventsApplication) {
@@ -328,10 +331,10 @@ public function handleCancelApplication(int $id): void
328331 $ application = $ this ->applicationRepository ->findById ($ id );
329332
330333 $ p = $ this ->getPresenter ();
334+ assert ($ p instanceof AdminBasePresenter);
331335
332336 if ($ application instanceof SubeventsApplication && ! $ application ->isCanceled ()) {
333- $ loggedUser = $ this ->userRepository ->findById ($ this ->getPresenter ()->user ->id );
334- $ this ->applicationService ->cancelSubeventsApplication ($ application , ApplicationState::CANCELED , $ loggedUser );
337+ $ this ->applicationService ->cancelSubeventsApplication ($ application , ApplicationState::CANCELED , $ p ->getDbUser ());
335338 $ p ->flashMessage ('admin.users.users_applications_application_canceled ' , 'success ' );
336339 }
337340
0 commit comments