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.1 Red Velvet API

  • Project:
    • CakePHP
      • CakePHP
      • Authentication
      • Authorization
      • Chronos
      • Elastic Search
      • Queue
  • Version:
    • 3.1
      • 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
    • Console
    • Controller
    • Core
    • Database
    • Datasource
    • Error
    • Event
    • Filesystem
    • Form
    • I18n
    • Log
    • Mailer
    • Network
    • ORM
    • Routing
    • Shell
    • TestSuite
    • Utility
    • Validation
    • View

Class Event

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.

Namespace: Cake\Event

Property Summary

  • $_name protected
    string

    Name of the event

  • $_stopped protected
    bool

    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

  • data() public

    Access the event data/payload.

  • isStopped() public

    Check if the event is stopped

  • name() public

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

  • stopPropagation() public

    Stops the event from being used anymore

  • subject() public

    Returns the subject of this event

Method Detail

__construct() ¶ public

__construct(string $name, object|null $subject = null, array|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

the object that this event applies to (usually the object that is generating the event)

array|null $data optional

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

__get() ¶ public

__get(string $attribute): mixed

Dynamically returns the name and subject if accessed directly

Parameters
string $attribute

Attribute name.

Returns
mixed

data() ¶ public

data(): array

Access the event data/payload.

Returns
array

isStopped() ¶ public

isStopped(): bool

Check if the event is stopped

Returns
bool

name() ¶ public

name(): string

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

Returns
string

stopPropagation() ¶ public

stopPropagation(): void

Stops the event from being used anymore

Returns
void

subject() ¶ public

subject(): object

Returns the subject of this event

Returns
object

Property Detail

$_name ¶ protected

Name of the event

Type
string

$_stopped ¶ protected

Flags an event as stopped or not, default is false

Type
bool

$_subject ¶ protected

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

Type
object

$data ¶ public

Custom data for the method that receives the event

Type
mixed

$result ¶ public

Property used to retain the result value of the event listeners

Type
mixed
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