]> source.dussan.org Git - nextcloud-server.git/commitdiff
Prefer typed event over string based ones 22169/head
authorMorris Jobke <hey@morrisjobke.de>
Mon, 10 Aug 2020 12:29:21 +0000 (14:29 +0200)
committerMorris Jobke <hey@morrisjobke.de>
Mon, 10 Aug 2020 13:22:55 +0000 (15:22 +0200)
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
apps/files/lib/Controller/ViewController.php
apps/workflowengine/lib/AppInfo/Application.php
apps/workflowengine/lib/Settings/ASettings.php
lib/private/Security/CSP/ContentSecurityPolicyManager.php
lib/private/Security/FeaturePolicy/FeaturePolicyManager.php

index 73ee589fdbc26ccd193dfdcb044d8864481bfc80..1568e0c9f548e45f68289d3bccfafd1b86e623ff 100644 (file)
@@ -278,9 +278,8 @@ class ViewController extends Controller {
                }
 
                $event = new LoadAdditionalScriptsEvent();
-               $this->eventDispatcher->dispatch(LoadAdditionalScriptsEvent::class, $event);
-
-               $this->eventDispatcher->dispatch(LoadSidebar::class, new LoadSidebar());
+               $this->eventDispatcher->dispatchTyped($event);
+               $this->eventDispatcher->dispatchTyped(new LoadSidebar());
                // Load Viewer scripts
                if (class_exists(LoadViewer::class)) {
                        $this->eventDispatcher->dispatchTyped(new LoadViewer());
index ddac4a74e28f5dd98f8855bccf2386c37e797ae8..8f762f0d707cff9ca9fbad818158a256af00bcdd 100644 (file)
@@ -36,6 +36,7 @@ use OCP\EventDispatcher\Event;
 use OCP\EventDispatcher\IEventDispatcher;
 use OCP\ILogger;
 use OCP\IServerContainer;
+use OCP\WorkflowEngine\Events\LoadSettingsScriptsEvent;
 use OCP\WorkflowEngine\IEntity;
 use OCP\WorkflowEngine\IEntityCompat;
 use OCP\WorkflowEngine\IOperation;
@@ -51,7 +52,7 @@ class Application extends App implements IBootstrap {
        public function register(IRegistrationContext $context): void {
                $context->registerServiceAlias('RequestTimeController', RequestTime::class);
                $context->registerEventListener(
-                       'OCP\WorkflowEngine::loadAdditionalSettingScripts',
+                       LoadSettingsScriptsEvent::class,
                        LoadAdditionalSettingsScriptsListener::class,
                        -100
                );
index 3d704e662eeae86784809940656b74c2a0a5b151..4d0d4312f16a4d610566dcef2a179f1c1a19c99e 100644 (file)
@@ -82,10 +82,12 @@ abstract class ASettings implements ISettings {
         * @return TemplateResponse
         */
        public function getForm() {
+               // @deprecated in 20.0.0: retire this one in favor of the typed event
                $this->eventDispatcher->dispatch(
                        'OCP\WorkflowEngine::loadAdditionalSettingScripts',
                        new LoadSettingsScriptsEvent()
                );
+               $this->eventDispatcher->dispatchTyped(new LoadSettingsScriptsEvent());
 
                $entities = $this->manager->getEntitiesList();
                $this->initialStateService->provideInitialState(
index e0403e77936959d548bc5ebfbdaa4b3641e18b45..47ba7ae4e01da827872d933c91dfcad1e2f663d5 100644 (file)
@@ -57,7 +57,7 @@ class ContentSecurityPolicyManager implements IContentSecurityPolicyManager {
         */
        public function getDefaultPolicy(): ContentSecurityPolicy {
                $event = new AddContentSecurityPolicyEvent($this);
-               $this->dispatcher->dispatch(AddContentSecurityPolicyEvent::class, $event);
+               $this->dispatcher->dispatchTyped($event);
 
                $defaultPolicy = new \OC\Security\CSP\ContentSecurityPolicy();
                foreach ($this->policies as $policy) {
index 6143a5b95fc940d349a899445c091b19d9a42919..c912c8480a4bbfb96a061d3300bb84da1fa47563 100644 (file)
@@ -47,7 +47,7 @@ class FeaturePolicyManager {
 
        public function getDefaultPolicy(): FeaturePolicy {
                $event = new AddFeaturePolicyEvent($this);
-               $this->dispatcher->dispatch(AddFeaturePolicyEvent::class, $event);
+               $this->dispatcher->dispatchTyped($event);
 
                $defaultPolicy = new FeaturePolicy();
                foreach ($this->policies as $policy) {