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
  1: <?php
  2: /**
  3:  *
  4:  * PHP 5
  5:  *
  6:  * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  7:  * Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
  8:  *
  9:  * Licensed under The MIT License
 10:  * Redistributions of files must retain the above copyright notice.
 11:  *
 12:  * @copyright     Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
 13:  * @link          http://cakephp.org CakePHP(tm) Project
 14:  * @package       Cake.Observer
 15:  * @since         CakePHP(tm) v 2.1
 16:  * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
 17:  */
 18: 
 19: /**
 20:  * Represent the transport class of events across the system, it receives a name, and subject and an optional
 21:  * payload. The name can be any string that uniquely identifies the event across the application, while the subject
 22:  * represents the object that the event is applying to.
 23:  *
 24:  * @package Cake.Event
 25:  */
 26: class CakeEvent {
 27: 
 28: /**
 29:  * Name of the event
 30:  * 
 31:  * @var string $name
 32:  */
 33:     protected $_name = null;
 34: 
 35: /**
 36:  * The object this event applies to (usually the same object that generates the event)
 37:  *
 38:  * @var object
 39:  */
 40:     protected $_subject;
 41: 
 42: /**
 43:  * Custom data for the method that receives the event
 44:  *
 45:  * @var mixed $data
 46:  */
 47:     public $data = null;
 48: 
 49: /**
 50:  * Property used to retain the result value of the event listeners
 51:  *
 52:  * @var mixed $result
 53:  */
 54:     public $result = null;
 55: 
 56: /**
 57:  * Flags an event as stopped or not, default is false
 58:  *
 59:  * @var boolean
 60:  */
 61:     protected $_stopped = false;
 62: 
 63: /**
 64:  * Constructor
 65:  *
 66:  * @param string $name Name of the event
 67:  * @param object $subject the object that this event applies to (usually the object that is generating the event)
 68:  * @param mixed $data any value you wish to be transported with this event to it can be read by listeners
 69:  *
 70:  * ## Examples of usage:
 71:  *
 72:  * {{{
 73:  *  $event = new CakeEvent('Order.afterBuy', $this, array('buyer' => $userData));
 74:  *  $event = new CakeEvent('User.afterRegister', $UserModel);
 75:  * }}}
 76:  *
 77:  */
 78:     public function __construct($name, $subject = null, $data = null) {
 79:         $this->_name = $name;
 80:         $this->data = $data;
 81:         $this->_subject = $subject;
 82:     }
 83: 
 84: /**
 85:  * Dynamically returns the name and subject if accessed directly
 86:  *
 87:  * @param string $attribute
 88:  * @return mixed
 89:  */
 90:     public function __get($attribute) {
 91:         if ($attribute === 'name' || $attribute === 'subject') {
 92:             return $this->{$attribute}();
 93:         }
 94:     }
 95: 
 96: /**
 97:  * Returns the name of this event. This is usually used as the event identifier
 98:  *
 99:  * @return string
100:  */
101:     public function name() {
102:         return $this->_name;
103:     }
104: 
105: /**
106:  * Returns the subject of this event
107:  *
108:  * @return string
109:  */
110:     public function subject() {
111:         return $this->_subject;
112:     }
113: 
114: /**
115:  * Stops the event from being used anymore
116:  *
117:  * @return void
118:  */
119:     public function stopPropagation() {
120:         return $this->_stopped = true;
121:     }
122: 
123: /**
124:  * Check if the event is stopped
125:  *
126:  * @return boolean True if the event is stopped
127:  */
128:     public function isStopped() {
129:         return $this->_stopped;
130:     }
131: 
132: }
133: 
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