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
    • Slack
    • Paid Support
CakePHP

C CakePHP 2.1 API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 2.1
      • 4.2
      • 4.1
      • 4.0
      • 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

Packages

  • Cake
    • Cache
      • Engine
    • Configure
    • Console
      • Command
        • Task
    • Controller
      • Component
        • Acl
        • Auth
    • Core
    • Error
    • Event
    • I18n
    • Log
      • Engine
    • Model
      • Behavior
      • Datasource
        • Database
        • Session
    • Network
      • Email
      • Http
    • Routing
      • Route
    • TestSuite
      • Coverage
      • Fixture
      • Reporter
    • Utility
    • View
      • Helper

Classes

  • CakeEvent
  • CakeEventManager

Interfaces

  • CakeEventListener

Class CakeEventManager

The event manager is responsible for keeping track of event listeners and pass the correct data to them, and fire them in the correct order, when associated events are triggered. You can create multiple instances of this objects to manage local events or keep a single instance and pass it around to manage all events in your app.

Package: Cake\Event
Copyright: Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
License: License (http://www.opensource.org/licenses/mit-license.php)
Location: Cake/Event/CakeEventManager.php

Properties summary

  • $_generalManager protected static
    CakeEventManager
    The globally available instance, used for dispatching events attached from any scope
  • $_isGlobal protected
    boolean
    Internal flag to distinguish a common manager from the sigleton
  • $_listeners protected
    object
    List of listener callbacks associated to
  • $defaultPriority public static
    integer
    The default priority queue value for new attached listeners

Method Summary

  • _attachSubscriber() protected

    Auxiliary function to attach all implemented callbacks of a CakeEventListener class instance as individual methods on this manager

  • _detachSubscriber() protected
    Auxiliary function to help detach all listeners provided by an object implementing CakeEventListener
  • _extractCallable() protected

    Auxiliary function to extract and return a PHP callback type out of the callable definition from the return value of the implementedEvents method on a CakeEventListener

  • attach() public
    Adds a new listener to an event. Listeners
  • detach() public
    Removes a listener from the active listeners.
  • dispatch() public
    Dispatches a new event to all configured listeners
  • instance() public static

    Returns the globally available instance of a CakeEventManager this is used for dispatching events attached from outside the scope other managers were created. Usually for creating hook systems or inter-class communication

  • listeners() public
    Returns a list of all listeners for a eventKey in the order they should be called

Method Detail

_attachSubscriber() protected ¶

_attachSubscriber( CakeEventListener $subscriber )

Auxiliary function to attach all implemented callbacks of a CakeEventListener class instance as individual methods on this manager

Parameters
CakeEventListener $subscriber

_detachSubscriber() protected ¶

_detachSubscriber( CakeEventListener $subscriber , string $eventKey = null )

Auxiliary function to help detach all listeners provided by an object implementing CakeEventListener

Parameters
CakeEventListener $subscriber
the subscriber to be detached
string $eventKey optional null
optional event key name to unsubscribe the listener from

_extractCallable() protected ¶

_extractCallable( array $function , CakeEventListener $object )

Auxiliary function to extract and return a PHP callback type out of the callable definition from the return value of the implementedEvents method on a CakeEventListener

Parameters
array $function
the array taken from a handler definition for a event
CakeEventListener $object
The handler object
Returns
callable

attach() public ¶

attach( callable|CakeEventListener $callable , mixed $eventKey = null , array $options = array() )

Adds a new listener to an event. Listeners

Parameters
callable|CakeEventListener $callable

PHP valid callback type or instance of CakeEventListener to be called when the event named with $eventKey is triggered. If a CakeEventListener instances is passed, then the implementedEvents method will be called on the object to register the declared events individually as methods to be managed by this class. It is possible to define multiple event handlers per event name.

mixed $eventKey optional null

The event unique identifier name to with the callback will be associated. If $callable is an instance of CakeEventListener this argument will be ignored

array $options optional array()

used to set the priority and passParams flags to the listener. Priorities are handled like queues, and multiple attachments into the same priority queue will be treated in the order of insertion. passParams means that the event data property will be converted to function arguments when the listener is called. If $called is an instance of CakeEventListener, this parameter will be ignored

Throws
InvalidArgumentException

When event key is missing or callable is not an instance of CakeEventListener.


detach() public ¶

detach( callable|CakeEventListener $callable , $eventKey = null )

Removes a listener from the active listeners.

Parameters
callable|CakeEventListener $callable
any valid PHP callback type or an instance of CakeEventListener
$eventKey optional null

dispatch() public ¶

dispatch( mixed $event )

Dispatches a new event to all configured listeners

Parameters
mixed $event
the event key name or instance of CakeEvent

instance() public static ¶

instance( CakeEventManager $manager = null )

Returns the globally available instance of a CakeEventManager this is used for dispatching events attached from outside the scope other managers were created. Usually for creating hook systems or inter-class communication

If called with a first params, it will be set as the globally available instance

Parameters
CakeEventManager $manager optional null
Returns
CakeEventManager
the global event manager

listeners() public ¶

listeners( string $eventKey )

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

Parameters
string $eventKey
Returns
array

Properties detail

$_generalManager ¶

protected static CakeEventManager

The globally available instance, used for dispatching events attached from any scope

null

$_isGlobal ¶

protected boolean

Internal flag to distinguish a common manager from the sigleton

false

$_listeners ¶

protected object

List of listener callbacks associated to

array()

$defaultPriority ¶

public static integer

The default priority queue value for new attached listeners

10
OpenHub
Rackspace
Rackspace
  • 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
  • Slack
  • Paid Support

Generated using CakePHP API Docs