Class CakeEvent

Represents the transport class of events across the system. It receives a name, subject and an optional payload. The name can be any string that uniquely identifies the event across the application, while the subject represents the object that the event applies to.

Package: Cake\Event
Copyright: Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
License: MIT License
Location: Cake/Event/CakeEvent.php

Properties summary

  • $_name protected
    string
    Name of the event
  • $_stopped protected
    boolean
    Flags an event as stopped or not, default is false
  • $_subject protected
    object
    The object this event applies to (usually the same object that generates the event)
  • $data public
    mixed
    Custom data for the method that receives the event
  • $result public
    mixed
    Property used to retain the result value of the event listeners

Method Summary

  • __construct() public
    Constructor
  • __get() public
    Dynamically returns the name and subject if accessed directly
  • isStopped() public
    Check if the event is stopped
  • name() public
    Returns the name of this event. This is usually used as the event identifier
  • Stops the event from being used anymore
  • subject() public
    Returns the subject of this event

Method Detail

__construct()source public

__construct( string $name , object $subject null , mixed $data null )

Constructor

Parameters

string $name
Name of the event
object $subject optional null
the object that this event applies to (usually the object that is generating the event)
mixed $data optional null

any value you wish to be transported with this event to it can be read by listeners

Examples of usage:

$event = new CakeEvent('Order.afterBuy', $this, array('buyer' => $userData));
$event = new CakeEvent('User.afterRegister', $UserModel);

__get()source public

__get( string $attribute )

Dynamically returns the name and subject if accessed directly

Parameters

string $attribute
Attribute name.

Returns

mixed

isStopped()source public

isStopped( )

Check if the event is stopped

Returns

boolean
True if the event is stopped

name()source public

name( )

Returns the name of this event. This is usually used as the event identifier

Returns

string

stopPropagation()source public

stopPropagation( )

Stops the event from being used anymore

subject()source public

subject( )

Returns the subject of this event

Returns

object

Properties detail

$_namesource

protected string

Name of the event

null

$_stoppedsource

protected boolean

Flags an event as stopped or not, default is false

false

$_subjectsource

protected object

The object this event applies to (usually the same object that generates the event)

$datasource

public mixed

Custom data for the method that receives the event

null

$resultsource

public mixed

Property used to retain the result value of the event listeners

null

© 2005–2017 The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/2.10/class-CakeEvent.html