@@ -23,53 +23,53 @@ |
||
| 23 | 23 | /** @template-implements IEventListener<BeforeTemplateRenderedEvent> */ |
| 24 | 24 | class BeforeTemplateRenderedListener implements IEventListener { |
| 25 | 25 | |
| 26 | - /** @var ProfileManager */ |
|
| 27 | - private $profileManager; |
|
| 26 | + /** @var ProfileManager */ |
|
| 27 | + private $profileManager; |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * BeforeTemplateRenderedListener constructor. |
|
| 31 | - * |
|
| 32 | - * @param ProfileManager $profileManager |
|
| 33 | - * @param IUserSession $userSession |
|
| 34 | - * @param IInitialStateService $initialState |
|
| 35 | - * @param JSDataService $jsDataService |
|
| 36 | - */ |
|
| 37 | - public function __construct( |
|
| 38 | - ProfileManager $profileManager, |
|
| 39 | - private IUserSession $userSession, |
|
| 40 | - private IInitialStateService $initialState, |
|
| 41 | - private JSDataService $jsDataService, |
|
| 42 | - ) { |
|
| 43 | - $this->profileManager = $profileManager; |
|
| 44 | - } |
|
| 29 | + /** |
|
| 30 | + * BeforeTemplateRenderedListener constructor. |
|
| 31 | + * |
|
| 32 | + * @param ProfileManager $profileManager |
|
| 33 | + * @param IUserSession $userSession |
|
| 34 | + * @param IInitialStateService $initialState |
|
| 35 | + * @param JSDataService $jsDataService |
|
| 36 | + */ |
|
| 37 | + public function __construct( |
|
| 38 | + ProfileManager $profileManager, |
|
| 39 | + private IUserSession $userSession, |
|
| 40 | + private IInitialStateService $initialState, |
|
| 41 | + private JSDataService $jsDataService, |
|
| 42 | + ) { |
|
| 43 | + $this->profileManager = $profileManager; |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * @inheritDoc |
|
| 48 | - */ |
|
| 49 | - public function handle(Event $event): void { |
|
| 50 | - $user = $this->userSession->getUser(); |
|
| 51 | - if ($user === null) { |
|
| 52 | - return; |
|
| 53 | - } |
|
| 46 | + /** |
|
| 47 | + * @inheritDoc |
|
| 48 | + */ |
|
| 49 | + public function handle(Event $event): void { |
|
| 50 | + $user = $this->userSession->getUser(); |
|
| 51 | + if ($user === null) { |
|
| 52 | + return; |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - if (!($event instanceof BeforeTemplateRenderedEvent)) { |
|
| 56 | - // Unrelated |
|
| 57 | - return; |
|
| 58 | - } |
|
| 55 | + if (!($event instanceof BeforeTemplateRenderedEvent)) { |
|
| 56 | + // Unrelated |
|
| 57 | + return; |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - if (!$event->isLoggedIn() || $event->getResponse()->getRenderAs() !== TemplateResponse::RENDER_AS_USER) { |
|
| 61 | - return; |
|
| 62 | - } |
|
| 60 | + if (!$event->isLoggedIn() || $event->getResponse()->getRenderAs() !== TemplateResponse::RENDER_AS_USER) { |
|
| 61 | + return; |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - $this->initialState->provideLazyInitialState(Application::APP_ID, 'status', function () { |
|
| 65 | - return $this->jsDataService; |
|
| 66 | - }); |
|
| 64 | + $this->initialState->provideLazyInitialState(Application::APP_ID, 'status', function () { |
|
| 65 | + return $this->jsDataService; |
|
| 66 | + }); |
|
| 67 | 67 | |
| 68 | - $this->initialState->provideLazyInitialState(Application::APP_ID, 'profileEnabled', function () use ($user) { |
|
| 69 | - return ['profileEnabled' => $this->profileManager->isProfileEnabled($user)]; |
|
| 70 | - }); |
|
| 68 | + $this->initialState->provideLazyInitialState(Application::APP_ID, 'profileEnabled', function () use ($user) { |
|
| 69 | + return ['profileEnabled' => $this->profileManager->isProfileEnabled($user)]; |
|
| 70 | + }); |
|
| 71 | 71 | |
| 72 | - Util::addScript('user_status', 'menu'); |
|
| 73 | - Util::addStyle('user_status', 'menu'); |
|
| 74 | - } |
|
| 72 | + Util::addScript('user_status', 'menu'); |
|
| 73 | + Util::addStyle('user_status', 'menu'); |
|
| 74 | + } |
|
| 75 | 75 | } |