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

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 3.7
      • 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
  1: <?php
  2: /**
  3:  * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
  4:  * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
  5:  *
  6:  * Licensed under The MIT License
  7:  * For full copyright and license information, please see the LICENSE.txt
  8:  * Redistributions of files must retain the above copyright notice.
  9:  *
 10:  * @copyright     Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
 11:  * @link          https://cakephp.org CakePHP(tm) Project
 12:  * @since         3.3.0
 13:  * @license       https://opensource.org/licenses/mit-license.php MIT License
 14:  */
 15: namespace Cake\Event;
 16: 
 17: use ArrayAccess;
 18: use Countable;
 19: 
 20: /**
 21:  * The Event List
 22:  */
 23: class EventList implements ArrayAccess, Countable
 24: {
 25: 
 26:     /**
 27:      * Events list
 28:      *
 29:      * @var \Cake\Event\Event[]
 30:      */
 31:     protected $_events = [];
 32: 
 33:     /**
 34:      * Empties the list of dispatched events.
 35:      *
 36:      * @return void
 37:      */
 38:     public function flush()
 39:     {
 40:         $this->_events = [];
 41:     }
 42: 
 43:     /**
 44:      * Adds an event to the list when event listing is enabled.
 45:      *
 46:      * @param \Cake\Event\Event $event An event to the list of dispatched events.
 47:      * @return void
 48:      */
 49:     public function add(Event $event)
 50:     {
 51:         $this->_events[] = $event;
 52:     }
 53: 
 54:     /**
 55:      * Whether a offset exists
 56:      *
 57:      * @link https://secure.php.net/manual/en/arrayaccess.offsetexists.php
 58:      * @param mixed $offset An offset to check for.
 59:      * @return bool True on success or false on failure.
 60:      */
 61:     public function offsetExists($offset)
 62:     {
 63:         return isset($this->_events[$offset]);
 64:     }
 65: 
 66:     /**
 67:      * Offset to retrieve
 68:      *
 69:      * @link https://secure.php.net/manual/en/arrayaccess.offsetget.php
 70:      * @param mixed $offset The offset to retrieve.
 71:      * @return mixed Can return all value types.
 72:      */
 73:     public function offsetGet($offset)
 74:     {
 75:         if ($this->offsetExists($offset)) {
 76:             return $this->_events[$offset];
 77:         }
 78: 
 79:         return null;
 80:     }
 81: 
 82:     /**
 83:      * Offset to set
 84:      *
 85:      * @link https://secure.php.net/manual/en/arrayaccess.offsetset.php
 86:      * @param mixed $offset The offset to assign the value to.
 87:      * @param mixed $value The value to set.
 88:      * @return void
 89:      */
 90:     public function offsetSet($offset, $value)
 91:     {
 92:         $this->_events[$offset] = $value;
 93:     }
 94: 
 95:     /**
 96:      * Offset to unset
 97:      *
 98:      * @link https://secure.php.net/manual/en/arrayaccess.offsetunset.php
 99:      * @param mixed $offset The offset to unset.
100:      * @return void
101:      */
102:     public function offsetUnset($offset)
103:     {
104:         unset($this->_events[$offset]);
105:     }
106: 
107:     /**
108:      * Count elements of an object
109:      *
110:      * @link https://secure.php.net/manual/en/countable.count.php
111:      * @return int The custom count as an integer.
112:      */
113:     public function count()
114:     {
115:         return count($this->_events);
116:     }
117: 
118:     /**
119:      * Checks if an event is in the list.
120:      *
121:      * @param string $name Event name.
122:      * @return bool
123:      */
124:     public function hasEvent($name)
125:     {
126:         foreach ($this->_events as $event) {
127:             if ($event->getName() === $name) {
128:                 return true;
129:             }
130:         }
131: 
132:         return false;
133:     }
134: }
135: 
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