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
  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:      * Events list
 27:      *
 28:      * @var \Cake\Event\Event[]
 29:      */
 30:     protected $_events = [];
 31: 
 32:     /**
 33:      * Empties the list of dispatched events.
 34:      *
 35:      * @return void
 36:      */
 37:     public function flush()
 38:     {
 39:         $this->_events = [];
 40:     }
 41: 
 42:     /**
 43:      * Adds an event to the list when event listing is enabled.
 44:      *
 45:      * @param \Cake\Event\Event $event An event to the list of dispatched events.
 46:      * @return void
 47:      */
 48:     public function add(Event $event)
 49:     {
 50:         $this->_events[] = $event;
 51:     }
 52: 
 53:     /**
 54:      * Whether a offset exists
 55:      *
 56:      * @link https://secure.php.net/manual/en/arrayaccess.offsetexists.php
 57:      * @param mixed $offset An offset to check for.
 58:      * @return bool True on success or false on failure.
 59:      */
 60:     public function offsetExists($offset)
 61:     {
 62:         return isset($this->_events[$offset]);
 63:     }
 64: 
 65:     /**
 66:      * Offset to retrieve
 67:      *
 68:      * @link https://secure.php.net/manual/en/arrayaccess.offsetget.php
 69:      * @param mixed $offset The offset to retrieve.
 70:      * @return mixed Can return all value types.
 71:      */
 72:     public function offsetGet($offset)
 73:     {
 74:         if ($this->offsetExists($offset)) {
 75:             return $this->_events[$offset];
 76:         }
 77: 
 78:         return null;
 79:     }
 80: 
 81:     /**
 82:      * Offset to set
 83:      *
 84:      * @link https://secure.php.net/manual/en/arrayaccess.offsetset.php
 85:      * @param mixed $offset The offset to assign the value to.
 86:      * @param mixed $value The value to set.
 87:      * @return void
 88:      */
 89:     public function offsetSet($offset, $value)
 90:     {
 91:         $this->_events[$offset] = $value;
 92:     }
 93: 
 94:     /**
 95:      * Offset to unset
 96:      *
 97:      * @link https://secure.php.net/manual/en/arrayaccess.offsetunset.php
 98:      * @param mixed $offset The offset to unset.
 99:      * @return void
100:      */
101:     public function offsetUnset($offset)
102:     {
103:         unset($this->_events[$offset]);
104:     }
105: 
106:     /**
107:      * Count elements of an object
108:      *
109:      * @link https://secure.php.net/manual/en/countable.count.php
110:      * @return int The custom count as an integer.
111:      */
112:     public function count()
113:     {
114:         return count($this->_events);
115:     }
116: 
117:     /**
118:      * Checks if an event is in the list.
119:      *
120:      * @param string $name Event name.
121:      * @return bool
122:      */
123:     public function hasEvent($name)
124:     {
125:         foreach ($this->_events as $event) {
126:             if ($event->getName() === $name) {
127:                 return true;
128:             }
129:         }
130: 
131:         return false;
132:     }
133: }
134: 
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