mirror of
https://github.com/brmlab/brmsklad.git
synced 2025-08-02 14:23:34 +02:00
Upgrade CakePHP from 2.2.5 to 2.9.5
This commit is contained in:
parent
5a580df460
commit
235a541597
793 changed files with 60746 additions and 23753 deletions
|
@ -1,25 +1,23 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* PHP 5
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* For full copyright and license information, please see the LICENSE.txt
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @package Cake.Observer
|
||||
* @since CakePHP(tm) v 2.1
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
|
||||
/**
|
||||
* Represent the transport class of events across the system, it receives a name, and subject and an optional
|
||||
* 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 is applying to.
|
||||
* represents the object that the event applies to.
|
||||
*
|
||||
* @package Cake.Event
|
||||
*/
|
||||
|
@ -28,7 +26,7 @@ class CakeEvent {
|
|||
/**
|
||||
* Name of the event
|
||||
*
|
||||
* @var string $name
|
||||
* @var string
|
||||
*/
|
||||
protected $_name = null;
|
||||
|
||||
|
@ -42,21 +40,21 @@ class CakeEvent {
|
|||
/**
|
||||
* Custom data for the method that receives the event
|
||||
*
|
||||
* @var mixed $data
|
||||
* @var mixed
|
||||
*/
|
||||
public $data = null;
|
||||
|
||||
/**
|
||||
* Property used to retain the result value of the event listeners
|
||||
*
|
||||
* @var mixed $result
|
||||
* @var mixed
|
||||
*/
|
||||
public $result = null;
|
||||
|
||||
/**
|
||||
* Flags an event as stopped or not, default is false
|
||||
*
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
protected $_stopped = false;
|
||||
|
||||
|
@ -69,11 +67,10 @@ class CakeEvent {
|
|||
*
|
||||
* ## Examples of usage:
|
||||
*
|
||||
* {{{
|
||||
* ```
|
||||
* $event = new CakeEvent('Order.afterBuy', $this, array('buyer' => $userData));
|
||||
* $event = new CakeEvent('User.afterRegister', $UserModel);
|
||||
* }}}
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
public function __construct($name, $subject = null, $data = null) {
|
||||
$this->_name = $name;
|
||||
|
@ -84,7 +81,7 @@ class CakeEvent {
|
|||
/**
|
||||
* Dynamically returns the name and subject if accessed directly
|
||||
*
|
||||
* @param string $attribute
|
||||
* @param string $attribute Attribute name.
|
||||
* @return mixed
|
||||
*/
|
||||
public function __get($attribute) {
|
||||
|
@ -105,7 +102,7 @@ class CakeEvent {
|
|||
/**
|
||||
* Returns the subject of this event
|
||||
*
|
||||
* @return string
|
||||
* @return object
|
||||
*/
|
||||
public function subject() {
|
||||
return $this->_subject;
|
||||
|
@ -123,7 +120,7 @@ class CakeEvent {
|
|||
/**
|
||||
* Check if the event is stopped
|
||||
*
|
||||
* @return boolean True if the event is stopped
|
||||
* @return bool True if the event is stopped
|
||||
*/
|
||||
public function isStopped() {
|
||||
return $this->_stopped;
|
||||
|
|
|
@ -1,36 +1,34 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* PHP 5
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* For full copyright and license information, please see the LICENSE.txt
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @package Cake.Observer
|
||||
* @since CakePHP(tm) v 2.1
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
|
||||
/**
|
||||
* Objects implementing this interface should declare the `implementedEvents` function
|
||||
* to hint the event manager what methods should be called when an event is triggered.
|
||||
* to notify the event manager what methods should be called when an event is triggered.
|
||||
*
|
||||
* @package Cake.Event
|
||||
*/
|
||||
interface CakeEventListener {
|
||||
interface CakeEventListener {
|
||||
|
||||
/**
|
||||
* Returns a list of events this object is implementing, when the class is registered
|
||||
* in an event manager, each individual method will be associated to the respective event.
|
||||
* Returns a list of events this object is implementing. When the class is registered
|
||||
* in an event manager, each individual method will be associated with the respective event.
|
||||
*
|
||||
* ## Example:
|
||||
*
|
||||
* {{{
|
||||
* ```
|
||||
* public function implementedEvents() {
|
||||
* return array(
|
||||
* 'Order.complete' => 'sendEmail',
|
||||
|
@ -38,7 +36,7 @@ interface CakeEventListener {
|
|||
* 'User.onRegister' => array('callable' => 'logRegistration', 'priority' => 20, 'passParams' => true)
|
||||
* );
|
||||
* }
|
||||
* }}}
|
||||
* ```
|
||||
*
|
||||
* @return array associative array or event key names pointing to the function
|
||||
* that should be called in the object when the respective event is fired
|
||||
|
|
|
@ -1,27 +1,25 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* PHP 5
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* For full copyright and license information, please see the LICENSE.txt
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @package Cake.Event
|
||||
* @since CakePHP(tm) v 2.1
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
|
||||
App::uses('CakeEventListener', 'Event');
|
||||
|
||||
/**
|
||||
* The event manager is responsible for keeping track of event listeners and pass the correct
|
||||
* data to them, and fire them in the correct order, when associated events are triggered. You
|
||||
* can create multiple instances of this objects to manage local events or keep a single instance
|
||||
* The event manager is responsible for keeping track of event listeners, passing the correct
|
||||
* data to them, and firing them in the correct order, when associated events are triggered. You
|
||||
* can create multiple instances of this object to manage local events or keep a single instance
|
||||
* and pass it around to manage all events in your app.
|
||||
*
|
||||
* @package Cake.Event
|
||||
|
@ -29,7 +27,7 @@ App::uses('CakeEventListener', 'Event');
|
|||
class CakeEventManager {
|
||||
|
||||
/**
|
||||
* The default priority queue value for new attached listeners
|
||||
* The default priority queue value for new, attached listeners
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
|
@ -45,14 +43,14 @@ class CakeEventManager {
|
|||
/**
|
||||
* List of listener callbacks associated to
|
||||
*
|
||||
* @var object $Listeners
|
||||
* @var object
|
||||
*/
|
||||
protected $_listeners = array();
|
||||
|
||||
/**
|
||||
* Internal flag to distinguish a common manager from the sigleton
|
||||
* Internal flag to distinguish a common manager from the singleton
|
||||
*
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
protected $_isGlobal = false;
|
||||
|
||||
|
@ -62,36 +60,36 @@ class CakeEventManager {
|
|||
* other managers were created. Usually for creating hook systems or inter-class
|
||||
* communication
|
||||
*
|
||||
* If called with a first params, it will be set as the globally available instance
|
||||
* If called with the first parameter, it will be set as the globally available instance
|
||||
*
|
||||
* @param CakeEventManager $manager
|
||||
* @param CakeEventManager $manager Optional event manager instance.
|
||||
* @return CakeEventManager the global event manager
|
||||
*/
|
||||
public static function instance($manager = null) {
|
||||
if ($manager instanceof CakeEventManager) {
|
||||
self::$_generalManager = $manager;
|
||||
static::$_generalManager = $manager;
|
||||
}
|
||||
if (empty(self::$_generalManager)) {
|
||||
self::$_generalManager = new CakeEventManager;
|
||||
if (empty(static::$_generalManager)) {
|
||||
static::$_generalManager = new CakeEventManager();
|
||||
}
|
||||
|
||||
self::$_generalManager->_isGlobal = true;
|
||||
return self::$_generalManager;
|
||||
static::$_generalManager->_isGlobal = true;
|
||||
return static::$_generalManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new listener to an event. Listeners
|
||||
*
|
||||
* @param callback|CakeEventListener $callable PHP valid callback type or instance of CakeEventListener to be called
|
||||
* when the event named with $eventKey is triggered. If a CakeEventListener instances is passed, then the `implementedEvents`
|
||||
* when the event named with $eventKey is triggered. If a CakeEventListener instance is passed, then the `implementedEvents`
|
||||
* method will be called on the object to register the declared events individually as methods to be managed by this class.
|
||||
* It is possible to define multiple event handlers per event name.
|
||||
*
|
||||
* @param string $eventKey The event unique identifier name to with the callback will be associated. If $callable
|
||||
* @param string $eventKey The event unique identifier name with which the callback will be associated. If $callable
|
||||
* is an instance of CakeEventListener this argument will be ignored
|
||||
*
|
||||
* @param array $options used to set the `priority` and `passParams` flags to the listener.
|
||||
* Priorities are handled like queues, and multiple attachments into the same priority queue will be treated in
|
||||
* Priorities are handled like queues, and multiple attachments added to the same priority queue will be treated in
|
||||
* the order of insertion. `passParams` means that the event data property will be converted to function arguments
|
||||
* when the listener is called. If $called is an instance of CakeEventListener, this parameter will be ignored
|
||||
*
|
||||
|
@ -107,7 +105,7 @@ class CakeEventManager {
|
|||
$this->_attachSubscriber($callable);
|
||||
return;
|
||||
}
|
||||
$options = $options + array('priority' => self::$defaultPriority, 'passParams' => false);
|
||||
$options = $options + array('priority' => static::$defaultPriority, 'passParams' => false);
|
||||
$this->_listeners[$eventKey][$options['priority']][] = array(
|
||||
'callable' => $callable,
|
||||
'passParams' => $options['passParams'],
|
||||
|
@ -118,11 +116,11 @@ class CakeEventManager {
|
|||
* Auxiliary function to attach all implemented callbacks of a CakeEventListener class instance
|
||||
* as individual methods on this manager
|
||||
*
|
||||
* @param CakeEventListener $subscriber
|
||||
* @param CakeEventListener $subscriber Event listener.
|
||||
* @return void
|
||||
*/
|
||||
protected function _attachSubscriber(CakeEventListener $subscriber) {
|
||||
foreach ($subscriber->implementedEvents() as $eventKey => $function) {
|
||||
foreach ((array)$subscriber->implementedEvents() as $eventKey => $function) {
|
||||
$options = array();
|
||||
$method = $function;
|
||||
if (is_array($function) && isset($function['callable'])) {
|
||||
|
@ -145,7 +143,7 @@ class CakeEventManager {
|
|||
* Auxiliary function to extract and return a PHP callback type out of the callable definition
|
||||
* from the return value of the `implementedEvents` method on a CakeEventListener
|
||||
*
|
||||
* @param array $function the array taken from a handler definition for a event
|
||||
* @param array $function the array taken from a handler definition for an event
|
||||
* @param CakeEventListener $object The handler object
|
||||
* @return callback
|
||||
*/
|
||||
|
@ -163,6 +161,7 @@ class CakeEventManager {
|
|||
* Removes a listener from the active listeners.
|
||||
*
|
||||
* @param callback|CakeEventListener $callable any valid PHP callback type or an instance of CakeEventListener
|
||||
* @param string $eventKey The event unique identifier name with which the callback has been associated
|
||||
* @return void
|
||||
*/
|
||||
public function detach($callable, $eventKey = null) {
|
||||
|
@ -196,7 +195,7 @@ class CakeEventManager {
|
|||
* @return void
|
||||
*/
|
||||
protected function _detachSubscriber(CakeEventListener $subscriber, $eventKey = null) {
|
||||
$events = $subscriber->implementedEvents();
|
||||
$events = (array)$subscriber->implementedEvents();
|
||||
if (!empty($eventKey) && empty($events[$eventKey])) {
|
||||
return;
|
||||
} elseif (!empty($eventKey)) {
|
||||
|
@ -221,22 +220,20 @@ class CakeEventManager {
|
|||
* Dispatches a new event to all configured listeners
|
||||
*
|
||||
* @param string|CakeEvent $event the event key name or instance of CakeEvent
|
||||
* @return void
|
||||
* @return CakeEvent
|
||||
* @triggers $event
|
||||
*/
|
||||
public function dispatch($event) {
|
||||
if (is_string($event)) {
|
||||
$event = new CakeEvent($event);
|
||||
}
|
||||
|
||||
if (!$this->_isGlobal) {
|
||||
self::instance()->dispatch($event);
|
||||
$listeners = $this->listeners($event->name());
|
||||
if (empty($listeners)) {
|
||||
return $event;
|
||||
}
|
||||
|
||||
if (empty($this->_listeners[$event->name()])) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($this->listeners($event->name()) as $listener) {
|
||||
foreach ($listeners as $listener) {
|
||||
if ($event->isStopped()) {
|
||||
break;
|
||||
}
|
||||
|
@ -251,26 +248,52 @@ class CakeEventManager {
|
|||
if ($result !== null) {
|
||||
$event->result = $result;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
return $event;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of all listeners for a eventKey in the order they should be called
|
||||
* Returns a list of all listeners for an eventKey in the order they should be called
|
||||
*
|
||||
* @param string $eventKey
|
||||
* @param string $eventKey Event key.
|
||||
* @return array
|
||||
*/
|
||||
public function listeners($eventKey) {
|
||||
if (empty($this->_listeners[$eventKey])) {
|
||||
return array();
|
||||
$localListeners = array();
|
||||
$priorities = array();
|
||||
if (!$this->_isGlobal) {
|
||||
$localListeners = $this->prioritisedListeners($eventKey);
|
||||
$localListeners = empty($localListeners) ? array() : $localListeners;
|
||||
}
|
||||
ksort($this->_listeners[$eventKey]);
|
||||
$globalListeners = static::instance()->prioritisedListeners($eventKey);
|
||||
$globalListeners = empty($globalListeners) ? array() : $globalListeners;
|
||||
|
||||
$priorities = array_merge(array_keys($globalListeners), array_keys($localListeners));
|
||||
$priorities = array_unique($priorities);
|
||||
asort($priorities);
|
||||
|
||||
$result = array();
|
||||
foreach ($this->_listeners[$eventKey] as $priorityQ) {
|
||||
$result = array_merge($result, $priorityQ);
|
||||
foreach ($priorities as $priority) {
|
||||
if (isset($globalListeners[$priority])) {
|
||||
$result = array_merge($result, $globalListeners[$priority]);
|
||||
}
|
||||
if (isset($localListeners[$priority])) {
|
||||
$result = array_merge($result, $localListeners[$priority]);
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the listeners for the specified event key indexed by priority
|
||||
*
|
||||
* @param string $eventKey Event key.
|
||||
* @return array
|
||||
*/
|
||||
public function prioritisedListeners($eventKey) {
|
||||
if (empty($this->_listeners[$eventKey])) {
|
||||
return array();
|
||||
}
|
||||
return $this->_listeners[$eventKey];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue