Documentation

Event
in package

FinalYes

Process queuing/execution class. Allows an unlimited number of callbacks to be added to 'events'. Events can be run multiple times, and can also process event-specific data. By default, Kohana has several system events.

$Id: Event.php 4390 2009-06-04 03:05:36Z zombor $

Tags
author

Kohana Team

copyright

(c) 2007 Kohana Team

license

http://kohanaphp.com/license.html

link
http://docs.kohanaphp.com/general/events

Table of Contents

Properties

$data  : mixed
Data that can be processed during events
$EVENTS  : mixed

Methods

add()  : bool
Add a callback to an event queue.
addAfter()  : bool
Add a callback to an event queue, after a given event.
addBefore()  : bool
Add a callback to an event queue, before a given event.
clear()  : void
Clear some or all callbacks from an event.
get()  : array<string|int, mixed>
Get all callbacks for an event.
hasRun()  : bool
Check if a given event has been run.
replace()  : bool
Replaces an event with another event.
run()  : void
Execute all of the callbacks attached to an event.
getEventClass()  : string

Properties

$data

Data that can be processed during events

public static mixed $data

$EVENTS

public static mixed $EVENTS = ['system.404' => \Sprout\Events\NotFoundEvent::class, 'system.shutdown' => \Sprout\Events\ShutdownEvent::class, 'system.pre_controller' => \Sprout\Events\PreControllerEvent::class, 'system.post_controller_constructor' => \Sprout\Events\PostControllerConstructorEvent::class, 'system.post_controller' => \Sprout\Events\PostControllerEvent::class, 'system.send_headers' => \Sprout\Events\SendHeadersEvent::class, 'system.display' => \Sprout\Events\DisplayEvent::class, 'system.session_write' => \Sprout\Events\SessionWriteEvent::class, 'system.redirect' => \Sprout\Events\RedirectEvent::class]

Methods

add()

Add a callback to an event queue.

public static add(string $name, callable $callback) : bool
Parameters
$name : string

event name

$callback : callable

http://php.net/callback

Return values
bool

addAfter()

Add a callback to an event queue, after a given event.

public static addAfter(string $name, array<string|int, mixed> $existing, callable $callback) : bool
Parameters
$name : string

event name

$existing : array<string|int, mixed>

existing event callback

$callback : callable

event callback

Return values
bool

addBefore()

Add a callback to an event queue, before a given event.

public static addBefore(string $name, array<string|int, mixed> $existing, callable $callback) : bool
Parameters
$name : string

event name

$existing : array<string|int, mixed>

existing event callback

$callback : callable

event callback

Return values
bool

clear()

Clear some or all callbacks from an event.

public static clear(string $name[, callable|false $callback = false ]) : void
Parameters
$name : string

event name

$callback : callable|false = false

specific callback to remove, FALSE for all callbacks

get()

Get all callbacks for an event.

public static get(string $name) : array<string|int, mixed>
Parameters
$name : string

event name

Return values
array<string|int, mixed>

hasRun()

Check if a given event has been run.

public static hasRun(string $name) : bool
Parameters
$name : string

event name

Return values
bool

replace()

Replaces an event with another event.

public static replace(string $name, callable $existing, callable $callback) : bool
Parameters
$name : string

event name

$existing : callable

event to replace

$callback : callable

new callback

Return values
bool

run()

Execute all of the callbacks attached to an event.

public static run(string $name[, mixed &$data = null ]) : void
Parameters
$name : string

event name

$data : mixed = null

data can be processed as Event::$data by the callbacks

getEventClass()

private static getEventClass(string $name) : string
Parameters
$name : string
Tags
throws
InvalidArgumentException
Return values
string
On this page

Search results