CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Team
    • Issues (Github)
    • YouTube Channel
    • Get Involved
    • Bakery
    • Featured Resources
    • Newsletter
    • Certification
    • My CakePHP
    • CakeFest
    • Facebook
    • Twitter
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C CakePHP 3.8 Red Velvet API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 3.8
      • 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

  • Cake
    • Auth
      • Storage
    • Cache
      • Engine
    • Collection
      • Iterator
    • Command
    • Console
      • Exception
    • Controller
      • Component
      • Exception
    • Core
      • Configure
        • Engine
      • Exception
      • Retry
    • Database
      • Driver
      • Exception
      • Expression
      • Schema
      • Statement
      • Type
    • Datasource
      • Exception
    • Error
      • Middleware
    • Event
      • Decorator
    • Filesystem
    • Form
    • Http
      • Client
        • Adapter
        • Auth
      • Cookie
      • Exception
      • Middleware
      • Session
    • I18n
      • Formatter
      • Middleware
      • Parser
    • Log
      • Engine
    • Mailer
      • Exception
      • Transport
    • Network
      • Exception
    • ORM
      • Association
      • Behavior
        • Translate
      • Exception
      • Locator
      • Rule
    • Routing
      • Exception
      • Filter
      • Middleware
      • Route
    • Shell
      • Helper
      • Task
    • TestSuite
      • Fixture
      • Stub
    • Utility
      • Exception
    • Validation
    • View
      • Exception
      • Form
      • Helper
      • Widget
  • None

Classes

  • Event
  • EventList
  • EventManager

Interfaces

  • EventDispatcherInterface
  • EventInterface
  • EventListenerInterface
  • EventManagerInterface

Traits

  • EventDispatcherTrait
  • EventManagerTrait

Class Event

Class Event

Cake\Event\Event implements Cake\Event\EventInterface
Namespace: Cake\Event
Location: Event/Event.php

Properties summary

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

Method Summary

  • __construct() public
    Constructor
  • __get() public deprecated
    Provides read-only access for the name and subject properties.
  • __set() public deprecated
    Provides backward compatibility for write access to data and result properties.
  • data() public deprecated
    Access the event data/payload.
  • getData() public
    Access the event data/payload.
  • getName() public
    Returns the name of this event. This is usually used as the event identifier
  • getResult() public
    The result value of the event listeners
  • getSubject() public
    Returns the subject of this event
  • isStopped() public
    Check if the event is stopped
  • name() public deprecated
    Returns the name of this event. This is usually used as the event identifier
  • result() public deprecated
    The result value of the event listeners
  • setData() public
    Assigns a value to the data/payload of this event.
  • setResult() public
    Listeners can attach a result value to the event.
  • stopPropagation() public
    Stops the event from being used anymore
  • subject() public deprecated
    Returns the subject of this event

Method Detail

__construct() public ¶

__construct( string $name , object|null $subject = null , array|ArrayAccess|null $data = null )

Constructor

Examples of usage:

$event = new Event('Order.afterBuy', $this, ['buyer' => $userData]);
 $event = new Event('User.afterRegister', $UserModel);
Parameters
string $name
Name of the event
object|null $subject optional null
the object that this event applies to (usually the object that is generating the event)
array|ArrayAccess|null $data optional null
any value you wish to be transported with this event to it can be read by listeners

__get() public deprecated ¶

__get( string $attribute )

Provides read-only access for the name and subject properties.

Deprecated
3.4.0 Public properties will be removed.
Parameters
string $attribute
Attribute name.
Returns
mixed

__set() public deprecated ¶

__set( string $attribute , mixed $value )

Provides backward compatibility for write access to data and result properties.

Deprecated
3.4.0 Public properties will be removed.
Parameters
string $attribute
Attribute name.
mixed $value
The value to set.

data() public deprecated ¶

data( string|null $key = null )

Access the event data/payload.

Deprecated
3.4.0 use getData() instead.
Parameters
string|null $key optional null
The data payload element to return, or null to return all data.
Returns
array|mixed|null

The data payload if $key is null, or the data value for the given $key. If the $key does not exist a null value is returned.


getData() public ¶

getData( string|null $key = null )

Access the event data/payload.

Parameters
string|null $key optional null
The data payload element to return, or null to return all data.
Returns
array|mixed|null

The data payload if $key is null, or the data value for the given $key. If the $key does not exist a null value is returned.


Implementation of
Cake\Event\EventInterface::getData()

getName() public ¶

getName( )

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

Returns
string
Implementation of
Cake\Event\EventInterface::getName()

getResult() public ¶

getResult( )

The result value of the event listeners

Returns
mixed
Implementation of
Cake\Event\EventInterface::getResult()

getSubject() public ¶

getSubject( )

Returns the subject of this event

Returns
object
Implementation of
Cake\Event\EventInterface::getSubject()

isStopped() public ¶

isStopped( )

Check if the event is stopped

Returns
boolean
True if the event is stopped
Implementation of
Cake\Event\EventInterface::isStopped()

name() public deprecated ¶

name( )

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

Deprecated
3.4.0 use getName() instead.
Returns
string

result() public deprecated ¶

result( )

The result value of the event listeners

Deprecated
3.4.0 use getResult() instead.
Returns
mixed

setData() public ¶

setData( array|string $key , mixed $value = null )

Assigns a value to the data/payload of this event.

Parameters
array|string $key
An array will replace all payload data, and a key will set just that array item.
mixed $value optional null
The value to set.
Returns

$this
Implementation of
Cake\Event\EventInterface::setData()

setResult() public ¶

setResult( mixed $value = null )

Listeners can attach a result value to the event.

Parameters
mixed $value optional null
The value to set.
Returns

$this
Implementation of
Cake\Event\EventInterface::setResult()

stopPropagation() public ¶

stopPropagation( )

Stops the event from being used anymore

Implementation of
Cake\Event\EventInterface::stopPropagation()

subject() public deprecated ¶

subject( )

Returns the subject of this event

Deprecated
3.4.0 use getSubject() instead.
Returns
object

Properties detail

$_data ¶

protected array

Custom data for the method that receives the event

$_name ¶

protected string

Name of the event

$_stopped ¶

protected boolean

Flags an event as stopped or not, default is false

false

$_subject ¶

protected object|null

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

$result ¶

public mixed

Property used to retain the result value of the event listeners

Note: Public access is deprecated, use setResult() and getResult() instead.

Follow @CakePHP
#IRC
OpenHub
Rackspace
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Logos & Trademarks
  • Community
  • Team
  • Issues (Github)
  • YouTube Channel
  • Get Involved
  • Bakery
  • Featured Resources
  • Newsletter
  • Certification
  • My CakePHP
  • CakeFest
  • Facebook
  • Twitter
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs