CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (Github)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C CakePHP 3.10 Red Velvet API

  • Project:
    • CakePHP
      • CakePHP
      • Authentication
      • Authorization
      • Chronos
      • Elastic Search
      • Queue
  • Version:
    • 3.10
      • 5.2
      • 5.1
      • 5.0
      • 4.6
      • 4.5
      • 4.4
      • 4.3
      • 4.2
      • 4.1
      • 4.0
      • 3.10
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Namespaces

  • Global
  • Cake
    • Auth
    • Cache
    • Collection
    • Command
    • Console
    • Controller
    • Core
    • Database
    • Datasource
    • Error
    • Event
      • Decorator
    • Filesystem
    • Form
    • Http
    • I18n
    • Log
    • Mailer
    • Network
    • ORM
    • Routing
    • Shell
    • TestSuite
    • Utility
    • Validation
    • View

Interface EventManagerInterface

Interface EventManagerInterface

Namespace: Cake\Event

Method Summary

  • dispatch() public

    Dispatches a new event to all configured listeners

  • listeners() public

    Returns a list of all listeners for an eventKey in the order they should be called

  • off() public

    Remove a listener from the active listeners.

  • on() public

    Adds a new listener to an event.

Method Detail

dispatch() ¶ public

dispatch(string|Cake\Event\EventInterface $event): Cake\Event\EventInterface

Dispatches a new event to all configured listeners

Parameters
string|Cake\Event\EventInterface $event

The event key name or instance of EventInterface.

Returns
Cake\Event\EventInterface

listeners() ¶ public

listeners(string $eventKey): array

Returns a list of all listeners for an eventKey in the order they should be called

Parameters
string $eventKey

Event key.

Returns
array

off() ¶ public

off(string|Cake\Event\EventListenerInterface $eventKey, callable|null $callable = null): $this

Remove a listener from the active listeners.

Remove a EventListenerInterface entirely:

$manager->off($listener);

Remove all listeners for a given event:

$manager->off('My.event');

Remove a specific listener:

$manager->off('My.event', $callback);

Remove a callback from all events:

$manager->off($callback);
Parameters
string|Cake\Event\EventListenerInterface $eventKey

The event unique identifier name with which the callback has been associated, or the $listener you want to remove.

callable|null $callable optional

The callback you want to detach.

Returns
$this

on() ¶ public

on(string|Cake\Event\EventListenerInterface|null $eventKey = null, array|callable $options = [], callable|null $callable = null): $this

Adds a new listener to an event.

A variadic interface to add listeners that emulates jQuery.on().

Binding an EventListenerInterface:

$eventManager->on($listener);

Binding with no options:

$eventManager->on('Model.beforeSave', $callable);

Binding with options:

$eventManager->on('Model.beforeSave', ['priority' => 90], $callable);
Parameters
string|Cake\Event\EventListenerInterface|null $eventKey optional

The event unique identifier name with which the callback will be associated. If $eventKey is an instance of Cake\Event\EventListenerInterface its events will be bound using the implementedEvents methods.

array|callable $options optional

Either an array of options or the callable you wish to bind to $eventKey. If an array of options, the priority key can be used to define the order. Priorities are treated as queues. Lower values are called before higher ones, and multiple attachments added to the same priority queue will be treated in the order of insertion.

callable|null $callable optional

The callable function you want invoked.

Returns
$this
Throws
InvalidArgumentException
When event key is missing or callable is not an instance of Cake\Event\EventListenerInterface.
OpenHub
Pingping
Linode
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (Github)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs