Prefer typed event over string based ones

Signed-off-by: Morris Jobke <hey@morrisjobke.de>
This commit is contained in:
Morris Jobke 2020-08-10 14:29:21 +02:00
parent 9c1ee2e0ba
commit c0be7e329f
No known key found for this signature in database
GPG Key ID: FE03C3A163FEDE68
5 changed files with 8 additions and 6 deletions

View File

@ -278,9 +278,8 @@ class ViewController extends Controller {
} }
$event = new LoadAdditionalScriptsEvent(); $event = new LoadAdditionalScriptsEvent();
$this->eventDispatcher->dispatch(LoadAdditionalScriptsEvent::class, $event); $this->eventDispatcher->dispatchTyped($event);
$this->eventDispatcher->dispatchTyped(new LoadSidebar());
$this->eventDispatcher->dispatch(LoadSidebar::class, new LoadSidebar());
// Load Viewer scripts // Load Viewer scripts
if (class_exists(LoadViewer::class)) { if (class_exists(LoadViewer::class)) {
$this->eventDispatcher->dispatchTyped(new LoadViewer()); $this->eventDispatcher->dispatchTyped(new LoadViewer());

View File

@ -36,6 +36,7 @@ use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventDispatcher; use OCP\EventDispatcher\IEventDispatcher;
use OCP\ILogger; use OCP\ILogger;
use OCP\IServerContainer; use OCP\IServerContainer;
use OCP\WorkflowEngine\Events\LoadSettingsScriptsEvent;
use OCP\WorkflowEngine\IEntity; use OCP\WorkflowEngine\IEntity;
use OCP\WorkflowEngine\IEntityCompat; use OCP\WorkflowEngine\IEntityCompat;
use OCP\WorkflowEngine\IOperation; use OCP\WorkflowEngine\IOperation;
@ -51,7 +52,7 @@ class Application extends App implements IBootstrap {
public function register(IRegistrationContext $context): void { public function register(IRegistrationContext $context): void {
$context->registerServiceAlias('RequestTimeController', RequestTime::class); $context->registerServiceAlias('RequestTimeController', RequestTime::class);
$context->registerEventListener( $context->registerEventListener(
'OCP\WorkflowEngine::loadAdditionalSettingScripts', LoadSettingsScriptsEvent::class,
LoadAdditionalSettingsScriptsListener::class, LoadAdditionalSettingsScriptsListener::class,
-100 -100
); );

View File

@ -82,10 +82,12 @@ abstract class ASettings implements ISettings {
* @return TemplateResponse * @return TemplateResponse
*/ */
public function getForm() { public function getForm() {
// @deprecated in 20.0.0: retire this one in favor of the typed event
$this->eventDispatcher->dispatch( $this->eventDispatcher->dispatch(
'OCP\WorkflowEngine::loadAdditionalSettingScripts', 'OCP\WorkflowEngine::loadAdditionalSettingScripts',
new LoadSettingsScriptsEvent() new LoadSettingsScriptsEvent()
); );
$this->eventDispatcher->dispatchTyped(new LoadSettingsScriptsEvent());
$entities = $this->manager->getEntitiesList(); $entities = $this->manager->getEntitiesList();
$this->initialStateService->provideInitialState( $this->initialStateService->provideInitialState(

View File

@ -57,7 +57,7 @@ class ContentSecurityPolicyManager implements IContentSecurityPolicyManager {
*/ */
public function getDefaultPolicy(): ContentSecurityPolicy { public function getDefaultPolicy(): ContentSecurityPolicy {
$event = new AddContentSecurityPolicyEvent($this); $event = new AddContentSecurityPolicyEvent($this);
$this->dispatcher->dispatch(AddContentSecurityPolicyEvent::class, $event); $this->dispatcher->dispatchTyped($event);
$defaultPolicy = new \OC\Security\CSP\ContentSecurityPolicy(); $defaultPolicy = new \OC\Security\CSP\ContentSecurityPolicy();
foreach ($this->policies as $policy) { foreach ($this->policies as $policy) {

View File

@ -47,7 +47,7 @@ class FeaturePolicyManager {
public function getDefaultPolicy(): FeaturePolicy { public function getDefaultPolicy(): FeaturePolicy {
$event = new AddFeaturePolicyEvent($this); $event = new AddFeaturePolicyEvent($this);
$this->dispatcher->dispatch(AddFeaturePolicyEvent::class, $event); $this->dispatcher->dispatchTyped($event);
$defaultPolicy = new FeaturePolicy(); $defaultPolicy = new FeaturePolicy();
foreach ($this->policies as $policy) { foreach ($this->policies as $policy) {