PHP 클래스 CakeEventManager

파일 보기 프로젝트 열기: baserproject/basercms 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$defaultPriority integer The default priority queue value for new, attached listeners

보호된 프로퍼티들

프로퍼티 타입 설명
$_generalManager CakeEventManager The globally available instance, used for dispatching events attached from any scope
$_isGlobal boolean Internal flag to distinguish a common manager from the singleton
$_listeners object List of listener callbacks associated to

공개 메소드들

메소드 설명
attach ( callback | CakeEventListener $callable, string $eventKey = null, array $options = [] ) : void Adds a new listener to an event. Listeners
detach ( callback | CakeEventListener $callable, string $eventKey = null ) : void Removes a listener from the active listeners.
dispatch ( string | CakeEvent $event ) : CakeEvent Dispatches a new event to all configured listeners
instance ( CakeEventManager $manager = null ) : CakeEventManager Returns the globally available instance of a CakeEventManager this is used for dispatching events attached from outside the scope other managers were created. Usually for creating hook systems or inter-class communication
listeners ( string $eventKey ) : array Returns a list of all listeners for an eventKey in the order they should be called
prioritisedListeners ( string $eventKey ) : array Returns the listeners for the specified event key indexed by priority

보호된 메소드들

메소드 설명
_attachSubscriber ( CakeEventListener $subscriber ) : void Auxiliary function to attach all implemented callbacks of a CakeEventListener class instance as individual methods on this manager
_detachSubscriber ( CakeEventListener $subscriber, string $eventKey = null ) : void Auxiliary function to help detach all listeners provided by an object implementing CakeEventListener
_extractCallable ( array $function, CakeEventListener $object ) : callback 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

메소드 상세

_attachSubscriber() 보호된 메소드

Auxiliary function to attach all implemented callbacks of a CakeEventListener class instance as individual methods on this manager
protected _attachSubscriber ( CakeEventListener $subscriber ) : void
$subscriber CakeEventListener
리턴 void

_detachSubscriber() 보호된 메소드

Auxiliary function to help detach all listeners provided by an object implementing CakeEventListener
protected _detachSubscriber ( CakeEventListener $subscriber, string $eventKey = null ) : void
$subscriber CakeEventListener the subscriber to be detached
$eventKey string optional event key name to unsubscribe the listener from
리턴 void

_extractCallable() 보호된 메소드

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
protected _extractCallable ( array $function, CakeEventListener $object ) : callback
$function array the array taken from a handler definition for an event
$object CakeEventListener The handler object
리턴 callback

attach() 공개 메소드

Adds a new listener to an event. Listeners
public attach ( callback | CakeEventListener $callable, string $eventKey = null, array $options = [] ) : void
$callable callback | CakeEventListener PHP valid callback type or instance of CakeEventListener to be called 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.
$eventKey string The event unique identifier name with which the callback will be associated. If $callable is an instance of CakeEventListener this argument will be ignored
$options array used to set the `priority` and `passParams` flags to the listener. 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
리턴 void

detach() 공개 메소드

Removes a listener from the active listeners.
public detach ( callback | CakeEventListener $callable, string $eventKey = null ) : void
$callable callback | CakeEventListener any valid PHP callback type or an instance of CakeEventListener
$eventKey string The event unique identifier name with which the callback has been associated
리턴 void

dispatch() 공개 메소드

Dispatches a new event to all configured listeners
public dispatch ( string | CakeEvent $event ) : CakeEvent
$event string | CakeEvent the event key name or instance of CakeEvent
리턴 CakeEvent

instance() 공개 정적인 메소드

If called with the first parameter, it will be set as the globally available instance
public static instance ( CakeEventManager $manager = null ) : CakeEventManager
$manager CakeEventManager
리턴 CakeEventManager the global event manager

listeners() 공개 메소드

Returns a list of all listeners for an eventKey in the order they should be called
public listeners ( string $eventKey ) : array
$eventKey string
리턴 array

prioritisedListeners() 공개 메소드

Returns the listeners for the specified event key indexed by priority
public prioritisedListeners ( string $eventKey ) : array
$eventKey string
리턴 array

프로퍼티 상세

$_generalManager 보호되어 있는 정적으로 프로퍼티

The globally available instance, used for dispatching events attached from any scope
protected static CakeEventManager $_generalManager
리턴 CakeEventManager

$_isGlobal 보호되어 있는 프로퍼티

Internal flag to distinguish a common manager from the singleton
protected bool $_isGlobal
리턴 boolean

$_listeners 보호되어 있는 프로퍼티

List of listener callbacks associated to
protected object $_listeners
리턴 object

$defaultPriority 공개적으로 정적으로 프로퍼티

The default priority queue value for new, attached listeners
public static int $defaultPriority
리턴 integer