diff options
author | Morris Jobke <hey@morrisjobke.de> | 2020-08-11 09:34:48 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-11 09:34:48 +0200 |
commit | bc4df68e561b2f8879657c9caa749e742cf08a70 (patch) | |
tree | ff46fa9c369f4791046472ff2c520fa705e6cc42 | |
parent | 24982808011df9d6aa14ced2d8790a18f4e2e747 (diff) | |
parent | c0be7e329f8a68ac70efb741a58530678c19a721 (diff) | |
download | nextcloud-server-bc4df68e561b2f8879657c9caa749e742cf08a70.tar.gz nextcloud-server-bc4df68e561b2f8879657c9caa749e742cf08a70.zip |
Merge pull request #22169 from nextcloud/enh/noid/prefer-typed-events
Prefer typed event over string based ones
5 files changed, 8 insertions, 6 deletions
diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php index 73ee589fdbc..1568e0c9f54 100644 --- a/apps/files/lib/Controller/ViewController.php +++ b/apps/files/lib/Controller/ViewController.php @@ -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()); diff --git a/apps/workflowengine/lib/AppInfo/Application.php b/apps/workflowengine/lib/AppInfo/Application.php index ddac4a74e28..8f762f0d707 100644 --- a/apps/workflowengine/lib/AppInfo/Application.php +++ b/apps/workflowengine/lib/AppInfo/Application.php @@ -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 ); diff --git a/apps/workflowengine/lib/Settings/ASettings.php b/apps/workflowengine/lib/Settings/ASettings.php index 3d704e662ee..4d0d4312f16 100644 --- a/apps/workflowengine/lib/Settings/ASettings.php +++ b/apps/workflowengine/lib/Settings/ASettings.php @@ -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( diff --git a/lib/private/Security/CSP/ContentSecurityPolicyManager.php b/lib/private/Security/CSP/ContentSecurityPolicyManager.php index e0403e77936..47ba7ae4e01 100644 --- a/lib/private/Security/CSP/ContentSecurityPolicyManager.php +++ b/lib/private/Security/CSP/ContentSecurityPolicyManager.php @@ -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) { diff --git a/lib/private/Security/FeaturePolicy/FeaturePolicyManager.php b/lib/private/Security/FeaturePolicy/FeaturePolicyManager.php index 6143a5b95fc..c912c8480a4 100644 --- a/lib/private/Security/FeaturePolicy/FeaturePolicyManager.php +++ b/lib/private/Security/FeaturePolicy/FeaturePolicyManager.php @@ -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) { |