Nextcloud PHP API (master)

IEventDispatcher

Event dispatcher service of Nextcloud

Tags
since
17.0.0

Table of Contents

Methods

addListener()  : void
addServiceListener()  : void
dispatch()  : void
dispatchTyped()  : void
Dispatch a typed event
hasListeners()  : bool
removeListener()  : void

Methods

addListener()

public addListener(string $eventName, callable $listener[, int $priority = 0 ]) : void
Parameters
$eventName : string

preferably the fully-qualified class name of the Event sub class

$listener : callable

the object that is invoked when a matching event is dispatched

$priority : int = 0

The higher this value, the earlier an event listener will be triggered in the chain (defaults to 0)

Tags
template

T of \OCP\EventDispatcher\Event

psalm-param

string|class-string<T> $eventName preferably the fully-qualified class name of the Event sub class

psalm-param

callable(T):void $listener

since
17.0.0

addServiceListener()

public addServiceListener(string $eventName, string $className[, int $priority = 0 ]) : void
Parameters
$eventName : string

preferably the fully-qualified class name of the Event sub class to listen for

$className : string

fully qualified class name (or ::class notation) of a \OCP\EventDispatcher\IEventListener that can be built by the DI container

$priority : int = 0

The higher this value, the earlier an event listener will be triggered in the chain (defaults to 0)

Tags
template

T of \OCP\EventDispatcher\Event

psalm-param

string|class-string<T> $eventName preferably the fully-qualified class name of the Event sub class to listen for

psalm-param

class-string<\OCP\EventDispatcher\IEventListener<T>> $className fully qualified class name that can be built by the DI container

since
17.0.0

dispatch()

public dispatch(string $eventName, Event $event) : void

use \OCP\EventDispatcher\IEventDispatcher::dispatchTyped

Parameters
$eventName : string
$event : Event
Tags
template

T of \OCP\EventDispatcher\Event

psalm-param

string|class-string<T> $eventName

psalm-param

T $event

since
17.0.0

dispatchTyped()

Dispatch a typed event

public dispatchTyped(Event $event) : void

Only use this with subclasses of \OCP\EventDispatcher\Event. The object's class will determine the event name.

Parameters
$event : Event
Tags
since
18.0.0

hasListeners()

public hasListeners(string $eventName) : bool
Parameters
$eventName : string

preferably the fully-qualified class name of the Event sub class

Tags
template

T of \OCP\EventDispatcher\Event

since
29.0.0
Return values
bool

TRUE if event has registered listeners

removeListener()

public removeListener(string $eventName, callable $listener) : void
Parameters
$eventName : string

preferably the fully-qualified class name of the Event sub class

$listener : callable

the object that is invoked when a matching event is dispatched

Tags
template

T of \OCP\EventDispatcher\Event

psalm-param

string|class-string<T> $eventName preferably the fully-qualified class name of the Event sub class

psalm-param

callable(T):void $listener

since
19.0.0

        
On this page

Search results