Skip to content

Commit c0be7e3

Browse files
committed
Prefer typed event over string based ones
Signed-off-by: Morris Jobke <[email protected]>
1 parent 9c1ee2e commit c0be7e3

File tree

5 files changed

+8
-6
lines changed

5 files changed

+8
-6
lines changed

apps/files/lib/Controller/ViewController.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,9 +278,8 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal
278278
}
279279

280280
$event = new LoadAdditionalScriptsEvent();
281-
$this->eventDispatcher->dispatch(LoadAdditionalScriptsEvent::class, $event);
282-
283-
$this->eventDispatcher->dispatch(LoadSidebar::class, new LoadSidebar());
281+
$this->eventDispatcher->dispatchTyped($event);
282+
$this->eventDispatcher->dispatchTyped(new LoadSidebar());
284283
// Load Viewer scripts
285284
if (class_exists(LoadViewer::class)) {
286285
$this->eventDispatcher->dispatchTyped(new LoadViewer());

apps/workflowengine/lib/AppInfo/Application.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
use OCP\EventDispatcher\IEventDispatcher;
3737
use OCP\ILogger;
3838
use OCP\IServerContainer;
39+
use OCP\WorkflowEngine\Events\LoadSettingsScriptsEvent;
3940
use OCP\WorkflowEngine\IEntity;
4041
use OCP\WorkflowEngine\IEntityCompat;
4142
use OCP\WorkflowEngine\IOperation;
@@ -51,7 +52,7 @@ public function __construct() {
5152
public function register(IRegistrationContext $context): void {
5253
$context->registerServiceAlias('RequestTimeController', RequestTime::class);
5354
$context->registerEventListener(
54-
'OCP\WorkflowEngine::loadAdditionalSettingScripts',
55+
LoadSettingsScriptsEvent::class,
5556
LoadAdditionalSettingsScriptsListener::class,
5657
-100
5758
);

apps/workflowengine/lib/Settings/ASettings.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,12 @@ abstract public function getScope(): int;
8282
* @return TemplateResponse
8383
*/
8484
public function getForm() {
85+
// @deprecated in 20.0.0: retire this one in favor of the typed event
8586
$this->eventDispatcher->dispatch(
8687
'OCP\WorkflowEngine::loadAdditionalSettingScripts',
8788
new LoadSettingsScriptsEvent()
8889
);
90+
$this->eventDispatcher->dispatchTyped(new LoadSettingsScriptsEvent());
8991

9092
$entities = $this->manager->getEntitiesList();
9193
$this->initialStateService->provideInitialState(

lib/private/Security/CSP/ContentSecurityPolicyManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function addDefaultPolicy(EmptyContentSecurityPolicy $policy) {
5757
*/
5858
public function getDefaultPolicy(): ContentSecurityPolicy {
5959
$event = new AddContentSecurityPolicyEvent($this);
60-
$this->dispatcher->dispatch(AddContentSecurityPolicyEvent::class, $event);
60+
$this->dispatcher->dispatchTyped($event);
6161

6262
$defaultPolicy = new \OC\Security\CSP\ContentSecurityPolicy();
6363
foreach ($this->policies as $policy) {

lib/private/Security/FeaturePolicy/FeaturePolicyManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function addDefaultPolicy(EmptyFeaturePolicy $policy): void {
4747

4848
public function getDefaultPolicy(): FeaturePolicy {
4949
$event = new AddFeaturePolicyEvent($this);
50-
$this->dispatcher->dispatch(AddFeaturePolicyEvent::class, $event);
50+
$this->dispatcher->dispatchTyped($event);
5151

5252
$defaultPolicy = new FeaturePolicy();
5353
foreach ($this->policies as $policy) {

0 commit comments

Comments
 (0)