JOOMLA中国
  • Joomla中国首页
  • 社区
  • 教程
  • 应用市场
  • B计划
Joomla! Framework TM
  • Namespace
  • Class
  • Tree
  • Deprecated

Namespaces

  • Composer
    • Autoload
  • Joomla
    • Application
      • Cli
        • Output
          • Processor
      • Web
    • Data
    • DI
      • Exception
    • Event
    • Filter
    • Input
    • Ldap
    • Registry
      • Format
    • Session
      • Storage
    • String
    • Uri
    • Utilities
  • None
  • PasswordCompat
    • binary
  • PHP
  • Psr
    • Log
  • Symfony
    • Component
      • Yaml
        • Exception
    • Polyfill
      • Util

Classes

  • AbstractEvent
  • DelegatingDispatcher
  • Dispatcher
  • Event
  • EventImmutable
  • ListenersPriorityQueue
  • Priority

Interfaces

  • DispatcherAwareInterface
  • DispatcherInterface
  • EventInterface

Traits

  • DispatcherAwareTrait

Class Dispatcher

Implementation of a DispatcherInterface supporting prioritized listeners.

Joomla\Event\Dispatcher implements Joomla\Event\DispatcherInterface
Namespace: Joomla\Event
Since: 1.0
Located at vendor/joomla/event/src/Dispatcher.php

Methods summary

public Joomla\Event\Dispatcher
# setEvent( Joomla\Event\EventInterface $event )

Set an event to the dispatcher. It will replace any event with the same name.

Set an event to the dispatcher. It will replace any event with the same name.

Parameters

$event
Joomla\Event\EventInterface - $event The event.

Returns

Joomla\Event\Dispatcher - This method is chainable.

Since

1.0
public Joomla\Event\Dispatcher
# setListenerFilter( string $regex )

Sets a regular expression to filter the class methods when adding a listener.

Sets a regular expression to filter the class methods when adding a listener.

Deprecated

Incorporate a method in your listener object such as getEvents to feed into the setListener method.

Parameters

$regex
string - $regex A regular expression (for example '^on' will only register methods starting with "on").

Returns

Joomla\Event\Dispatcher - This method is chainable.

Since

1.0
public Joomla\Event\Dispatcher
# addEvent( Joomla\Event\EventInterface $event )

Add an event to this dispatcher, only if it is not existing.

Add an event to this dispatcher, only if it is not existing.

Parameters

$event
Joomla\Event\EventInterface - $event The event.

Returns

Joomla\Event\Dispatcher - This method is chainable.

Since

1.0
public boolean
# hasEvent( Joomla\Event\EventInterface|string $event )

Tell if the given event has been added to this dispatcher.

Tell if the given event has been added to this dispatcher.

Parameters

$event
Joomla\Event\EventInterface|string - $event The event object or name.

Returns

boolean - True if the listener has the given event, false otherwise.

Since

1.0
public Joomla\Event\EventInterface|mixed
# getEvent( string $name, mixed $default = null )

Get the event object identified by the given name.

Get the event object identified by the given name.

Parameters

$name
string - $name The event name.
$default
mixed - $default The default value if the event was not registered.

Returns

Joomla\Event\EventInterface|mixed - The event of the default value.

Since

1.0
public Joomla\Event\Dispatcher
# removeEvent( Joomla\Event\EventInterface|string $event )

Remove an event from this dispatcher. The registered listeners will remain.

Remove an event from this dispatcher. The registered listeners will remain.

Parameters

$event
Joomla\Event\EventInterface|string - $event The event object or name.

Returns

Joomla\Event\Dispatcher - This method is chainable.

Since

1.0
public Joomla\Event\EventInterface[]
# getEvents( )

Get the registered events.

Get the registered events.

Returns

Joomla\Event\EventInterface[] - The registered event.

Since

1.0
public Joomla\Event\EventInterface[]
# clearEvents( )

Clear all events.

Clear all events.

Returns

Joomla\Event\EventInterface[] - The old events.

Since

1.0
public integer
# countEvents( )

Count the number of registered event.

Count the number of registered event.

Returns

integer - The numer of registered events.

Since

1.0
public Joomla\Event\Dispatcher
# addListener( object|Closure $listener, array $events = array() )

Add a listener to this dispatcher, only if not already registered to these events. If no events are specified, it will be registered to all events matching it's methods name. In the case of a closure, you must specify at least one event name.

Add a listener to this dispatcher, only if not already registered to these events. If no events are specified, it will be registered to all events matching it's methods name. In the case of a closure, you must specify at least one event name.

Parameters

$listener
object|Closure - $listener The listener
$events
array - $events An associative array of event names as keys and the corresponding listener priority as values.

Returns

Joomla\Event\Dispatcher - This method is chainable.

Throws

InvalidArgumentException

Since

1.0
public mixed
# getListenerPriority( object|Closure $listener, Joomla\Event\EventInterface|string $event )

Get the priority of the given listener for the given event.

Get the priority of the given listener for the given event.

Parameters

$listener
object|Closure - $listener The listener.
$event
Joomla\Event\EventInterface|string - $event The event object or name.

Returns

mixed - The listener priority or null if the listener doesn't exist.

Since

1.0
public object[]
# getListeners( Joomla\Event\EventInterface|string $event )

Get the listeners registered to the given event.

Get the listeners registered to the given event.

Parameters

$event
Joomla\Event\EventInterface|string - $event The event object or name.

Returns

object[] - An array of registered listeners sorted according to their priorities.

Since

1.0
public boolean
# hasListener( object|Closure $listener, Joomla\Event\EventInterface|string $event = null )

Tell if the given listener has been added. If an event is specified, it will tell if the listener is registered for that event.

Tell if the given listener has been added. If an event is specified, it will tell if the listener is registered for that event.

Parameters

$listener
object|Closure - $listener The listener.
$event
Joomla\Event\EventInterface|string - $event The event object or name.

Returns

boolean - True if the listener is registered, false otherwise.

Since

1.0
public Joomla\Event\Dispatcher
# removeListener( object|Closure $listener, Joomla\Event\EventInterface|string $event = null )

Remove the given listener from this dispatcher. If no event is specified, it will be removed from all events it is listening to.

Remove the given listener from this dispatcher. If no event is specified, it will be removed from all events it is listening to.

Parameters

$listener
object|Closure - $listener The listener to remove.
$event
Joomla\Event\EventInterface|string - $event The event object or name.

Returns

Joomla\Event\Dispatcher - This method is chainable.

Since

1.0
public Joomla\Event\Dispatcher
# clearListeners( Joomla\Event\EventInterface|string $event = null )

Clear the listeners in this dispatcher. If an event is specified, the listeners will be cleared only for that event.

Clear the listeners in this dispatcher. If an event is specified, the listeners will be cleared only for that event.

Parameters

$event
Joomla\Event\EventInterface|string - $event The event object or name.

Returns

Joomla\Event\Dispatcher - This method is chainable.

Since

1.0
public integer
# countListeners( Joomla\Event\EventInterface|string $event )

Count the number of registered listeners for the given event.

Count the number of registered listeners for the given event.

Parameters

$event
Joomla\Event\EventInterface|string - $event The event object or name.

Returns

integer - The number of registered listeners for the given event.

Since

1.0
public Joomla\Event\EventInterface
# triggerEvent( Joomla\Event\EventInterface|string $event )

Trigger an event.

Trigger an event.

Parameters

$event
Joomla\Event\EventInterface|string - $event The event object or name.

Returns

Joomla\Event\EventInterface - The event after being passed through all listeners.

Since

1.0

Implementation of

Joomla\Event\DispatcherInterface::triggerEvent()

Magic methods summary

Properties summary

protected Joomla\Event\EventInterface[] $events
#

An array of registered events indexed by the event names.

An array of registered events indexed by the event names.

Since

1.0
protected string $listenerFilter
#

A regular expression that will filter listener method names.

A regular expression that will filter listener method names.

Deprecated

Since

1.0
protected Joomla\Event\ListenersPriorityQueue[] $listeners
#

An array of ListenersPriorityQueue indexed by the event names.

An array of ListenersPriorityQueue indexed by the event names.

Since

1.0
Joomla! Framework TM API documentation generated by ApiGen 2.8.0
Joomla!® and Joomla! Framework™ are trademarks of Open Source Matters, Inc. in the United States and other countries.