@@ -35,42 +35,42 @@ |
||
35 | 35 | |
36 | 36 | class BeforeTemplateRenderedListener implements IEventListener { |
37 | 37 | |
38 | - /** @var IInitialStateService */ |
|
39 | - private $initialState; |
|
38 | + /** @var IInitialStateService */ |
|
39 | + private $initialState; |
|
40 | 40 | |
41 | - /** @var JSDataService */ |
|
42 | - private $jsDataService; |
|
41 | + /** @var JSDataService */ |
|
42 | + private $jsDataService; |
|
43 | 43 | |
44 | - /** |
|
45 | - * BeforeTemplateRenderedListener constructor. |
|
46 | - * |
|
47 | - * @param IInitialStateService $initialState |
|
48 | - * @param JSDataService $jsDataService |
|
49 | - */ |
|
50 | - public function __construct(IInitialStateService $initialState, |
|
51 | - JSDataService $jsDataService) { |
|
52 | - $this->initialState = $initialState; |
|
53 | - $this->jsDataService = $jsDataService; |
|
54 | - } |
|
44 | + /** |
|
45 | + * BeforeTemplateRenderedListener constructor. |
|
46 | + * |
|
47 | + * @param IInitialStateService $initialState |
|
48 | + * @param JSDataService $jsDataService |
|
49 | + */ |
|
50 | + public function __construct(IInitialStateService $initialState, |
|
51 | + JSDataService $jsDataService) { |
|
52 | + $this->initialState = $initialState; |
|
53 | + $this->jsDataService = $jsDataService; |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * @inheritDoc |
|
58 | - */ |
|
59 | - public function handle(Event $event): void { |
|
60 | - if (!($event instanceof BeforeTemplateRenderedEvent)) { |
|
61 | - // Unrelated |
|
62 | - return; |
|
63 | - } |
|
56 | + /** |
|
57 | + * @inheritDoc |
|
58 | + */ |
|
59 | + public function handle(Event $event): void { |
|
60 | + if (!($event instanceof BeforeTemplateRenderedEvent)) { |
|
61 | + // Unrelated |
|
62 | + return; |
|
63 | + } |
|
64 | 64 | |
65 | - if (!$event->isLoggedIn() || $event->getResponse()->getRenderAs() !== TemplateResponse::RENDER_AS_USER) { |
|
66 | - return; |
|
67 | - } |
|
65 | + if (!$event->isLoggedIn() || $event->getResponse()->getRenderAs() !== TemplateResponse::RENDER_AS_USER) { |
|
66 | + return; |
|
67 | + } |
|
68 | 68 | |
69 | - $this->initialState->provideLazyInitialState(Application::APP_ID, 'status', function () { |
|
70 | - return $this->jsDataService; |
|
71 | - }); |
|
69 | + $this->initialState->provideLazyInitialState(Application::APP_ID, 'status', function () { |
|
70 | + return $this->jsDataService; |
|
71 | + }); |
|
72 | 72 | |
73 | - \OCP\Util::addScript('user_status', 'user-status-menu'); |
|
74 | - \OCP\Util::addStyle('user_status', 'user-status-menu'); |
|
75 | - } |
|
73 | + \OCP\Util::addScript('user_status', 'user-status-menu'); |
|
74 | + \OCP\Util::addStyle('user_status', 'user-status-menu'); |
|
75 | + } |
|
76 | 76 | } |
@@ -40,40 +40,40 @@ |
||
40 | 40 | use Symfony\Component\EventDispatcher\EventDispatcherInterface; |
41 | 41 | |
42 | 42 | class AdditionalScriptsMiddleware extends Middleware { |
43 | - /** @var EventDispatcherInterface */ |
|
44 | - private $legacyDispatcher; |
|
45 | - /** @var IUserSession */ |
|
46 | - private $userSession; |
|
47 | - /** @var IEventDispatcher */ |
|
48 | - private $dispatcher; |
|
43 | + /** @var EventDispatcherInterface */ |
|
44 | + private $legacyDispatcher; |
|
45 | + /** @var IUserSession */ |
|
46 | + private $userSession; |
|
47 | + /** @var IEventDispatcher */ |
|
48 | + private $dispatcher; |
|
49 | 49 | |
50 | - public function __construct(EventDispatcherInterface $legacyDispatcher, IUserSession $userSession, IEventDispatcher $dispatcher) { |
|
51 | - $this->legacyDispatcher = $legacyDispatcher; |
|
52 | - $this->userSession = $userSession; |
|
53 | - $this->dispatcher = $dispatcher; |
|
54 | - } |
|
50 | + public function __construct(EventDispatcherInterface $legacyDispatcher, IUserSession $userSession, IEventDispatcher $dispatcher) { |
|
51 | + $this->legacyDispatcher = $legacyDispatcher; |
|
52 | + $this->userSession = $userSession; |
|
53 | + $this->dispatcher = $dispatcher; |
|
54 | + } |
|
55 | 55 | |
56 | - public function afterController($controller, $methodName, Response $response): Response { |
|
57 | - if ($response instanceof TemplateResponse) { |
|
58 | - if (!$controller instanceof PublicShareController) { |
|
59 | - /* |
|
56 | + public function afterController($controller, $methodName, Response $response): Response { |
|
57 | + if ($response instanceof TemplateResponse) { |
|
58 | + if (!$controller instanceof PublicShareController) { |
|
59 | + /* |
|
60 | 60 | * The old event was not dispatched on the public share controller as there was |
61 | 61 | * OCA\Files_Sharing::loadAdditionalScripts for that. This is kept for compatibility reasons |
62 | 62 | * only for the old event as this is now also included in BeforeTemplateRenderedEvent |
63 | 63 | */ |
64 | - $this->legacyDispatcher->dispatch(TemplateResponse::EVENT_LOAD_ADDITIONAL_SCRIPTS, new GenericEvent()); |
|
65 | - } |
|
64 | + $this->legacyDispatcher->dispatch(TemplateResponse::EVENT_LOAD_ADDITIONAL_SCRIPTS, new GenericEvent()); |
|
65 | + } |
|
66 | 66 | |
67 | - if (!($response instanceof StandaloneTemplateResponse) && $this->userSession->isLoggedIn()) { |
|
68 | - $this->legacyDispatcher->dispatch(TemplateResponse::EVENT_LOAD_ADDITIONAL_SCRIPTS_LOGGEDIN, new GenericEvent()); |
|
69 | - $isLoggedIn = true; |
|
70 | - } else { |
|
71 | - $isLoggedIn = false; |
|
72 | - } |
|
67 | + if (!($response instanceof StandaloneTemplateResponse) && $this->userSession->isLoggedIn()) { |
|
68 | + $this->legacyDispatcher->dispatch(TemplateResponse::EVENT_LOAD_ADDITIONAL_SCRIPTS_LOGGEDIN, new GenericEvent()); |
|
69 | + $isLoggedIn = true; |
|
70 | + } else { |
|
71 | + $isLoggedIn = false; |
|
72 | + } |
|
73 | 73 | |
74 | - $this->dispatcher->dispatchTyped(new BeforeTemplateRenderedEvent($isLoggedIn, $response)); |
|
75 | - } |
|
74 | + $this->dispatcher->dispatchTyped(new BeforeTemplateRenderedEvent($isLoggedIn, $response)); |
|
75 | + } |
|
76 | 76 | |
77 | - return $response; |
|
78 | - } |
|
77 | + return $response; |
|
78 | + } |
|
79 | 79 | } |
@@ -37,32 +37,32 @@ |
||
37 | 37 | * @since 20.0.0 |
38 | 38 | */ |
39 | 39 | class BeforeTemplateRenderedEvent extends Event { |
40 | - /** @var bool */ |
|
41 | - private $loggedIn; |
|
42 | - /** @var TemplateResponse */ |
|
43 | - private $response; |
|
40 | + /** @var bool */ |
|
41 | + private $loggedIn; |
|
42 | + /** @var TemplateResponse */ |
|
43 | + private $response; |
|
44 | 44 | |
45 | - /** |
|
46 | - * @since 20.0.0 |
|
47 | - */ |
|
48 | - public function __construct(bool $loggedIn, TemplateResponse $response) { |
|
49 | - parent::__construct(); |
|
45 | + /** |
|
46 | + * @since 20.0.0 |
|
47 | + */ |
|
48 | + public function __construct(bool $loggedIn, TemplateResponse $response) { |
|
49 | + parent::__construct(); |
|
50 | 50 | |
51 | - $this->loggedIn = $loggedIn; |
|
52 | - $this->response = $response; |
|
53 | - } |
|
51 | + $this->loggedIn = $loggedIn; |
|
52 | + $this->response = $response; |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * @since 20.0.0 |
|
57 | - */ |
|
58 | - public function isLoggedIn(): bool { |
|
59 | - return $this->loggedIn; |
|
60 | - } |
|
55 | + /** |
|
56 | + * @since 20.0.0 |
|
57 | + */ |
|
58 | + public function isLoggedIn(): bool { |
|
59 | + return $this->loggedIn; |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * @since 20.0.0 |
|
64 | - */ |
|
65 | - public function getResponse(): TemplateResponse { |
|
66 | - return $this->response; |
|
67 | - } |
|
62 | + /** |
|
63 | + * @since 20.0.0 |
|
64 | + */ |
|
65 | + public function getResponse(): TemplateResponse { |
|
66 | + return $this->response; |
|
67 | + } |
|
68 | 68 | } |