SproutCMS

This is the code documentation for the SproutCMS project

class Event

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 $

Source code (13 results)

/sprout/composer_bootstrap.php   Highlighted file source

Line 49: require_once APPPATH . 'core/Event.php';

/sprout/Controllers/BaseController.php   Highlighted file source

Line 19: use Event;
Line 78: Event::run('system.404');

/sprout/core/Bootstrap.php   Highlighted file source

Line 38: require APPPATH . 'core/Event.php';
Line 65: Event::run('system.shutdown');
Line 96: Event::run('system.404');
Line 103: Event::run('system.shutdown');

/sprout/core/Event.php   Highlighted file source

Line 16: * to be added to 'events'. Events can be run multiple times, and can also
Line 17: * process event-specific data. By default, Kohana has several system events.
Line 19: * $Id: Event.php 4390 2009-06-04 03:05:36Z zombor $
Line 25: * @link http://docs.kohanaphp.com/general/events
Line 27: final class Event {
Line 29: // Event callbacks
Line 30: private static $events = array();
Line 32: // Cache of events that have been run
Line 35: // Data that can be processed during events
Line 39: * Add a callback to an event queue.
Line 41: * @param string event name
Line 47: if ( ! isset(self::$events[$name]))
Line 49: // Create an empty event if it is not yet defined
Line 50: self::$events[$name] = array();
Line 52: elseif (in_array($callback, self::$events[$name], TRUE))
Line 54: // The event already exists
Line 58: // Add the event
Line 59: self::$events[$name][] = $callback;
Line 65: * Add a callback to an event queue, before a given event.
Line 67: * @param string event name
Line 68: * @param array existing event callback
Line 69: * @param array event callback
Line 74: if (empty(self::$events[$name]) OR ($key = array_search($existing, self::$events[$name])) === FALSE)
Line 76: // Just add the event if there are no events
Line 81: // Insert the event immediately before the existing event
Line 82: return self::insertEvent($name, $key, $callback);
Line 87: * Add a callback to an event queue, after a given event.
Line 89: * @param string event name
Line 90: * @param array existing event callback
Line 91: * @param array event callback
Line 96: if (empty(self::$events[$name]) OR ($key = array_search($existing, self::$events[$name])) === FALSE)
Line 98: // Just add the event if there are no events
Line 103: // Insert the event immediately after the existing event
Line 104: return self::insertEvent($name, $key + 1, $callback);
Line 109: * Inserts a new event at a specfic key location.
Line 111: * @param string event name
Line 112: * @param integer key to insert new event at
Line 113: * @param array event callback
Line 116: private static function insertEvent($name, $key, $callback)
Line 118: if (in_array($callback, self::$events[$name], TRUE))
Line 121: // Add the new event at the given key location
Line 122: self::$events[$name] = array_merge
Line 124: // Events before the key
Line 125: array_slice(self::$events[$name], 0, $key),
Line 126: // New event callback
Line 128: // Events after the key
Line 129: array_slice(self::$events[$name], $key)
Line 136: * Replaces an event with another event.
Line 138: * @param string event name
Line 139: * @param array event to replace
Line 145: if (empty(self::$events[$name]) OR ($key = array_search($existing, self::$events[$name], TRUE)) === FALSE)
Line 148: if ( ! in_array($callback, self::$events[$name], TRUE))
Line 150: // Replace the exisiting event with the new event
Line 151: self::$events[$name][$key] = $callback;
Line 155: // Remove the existing event from the queue
Line 156: unset(self::$events[$name][$key]);
Line 159: self::$events[$name] = array_values(self::$events[$name]);
Line 166: * Get all callbacks for an event.
Line 168: * @param string event name
Line 173: return empty(self::$events[$name]) ? array() : self::$events[$name];
Line 177: * Clear some or all callbacks from an event.
Line 179: * @param string event name
Line 187: self::$events[$name] = array();
Line 189: elseif (isset(self::$events[$name]))
Line 191: // Loop through each of the event callbacks and compare it to the
Line 194: foreach (self::$events[$name] as $i => $event_callback)
Line 196: if ($callback === $event_callback)
Line 198: unset(self::$events[$name][$i]);
Line 205: * Execute all of the callbacks attached to an event.
Line 207: * @param string event name
Line 208: * @param array data can be processed as Event::$data by the callbacks
Line 213: if ( ! empty(self::$events[$name]))
Line 215: // So callbacks can access Event::$data
Line 224: // Do this to prevent data from getting 'stuck'
Line 229: // The event has been run!
Line 234: * Check if a given event has been run.
Line 236: * @param string event name
Line 244: } // End Event

/sprout/core/Kohana.php   Highlighted file source

Line 109: Event::add('system.shutdown', array(__CLASS__, 'internalCacheSave'));
Line 164: Event::add('system.404', array('Kohana', 'show404'));
Line 167: Event::add('system.shutdown', array('Kohana', 'shutdown'));
Line 169: Event::add('system.display', array('Sprout\\Helpers\\Needs', 'replacePlaceholders'));
Line 170: Event::add('system.display', array('Sprout\\Helpers\\SessionStats', 'trackPageView'));
Line 172: // Setup is complete, prevent it from being run again
Line 178: * post_controller_constructor, and post_controller events. Triggers
Line 179: * a system.404 event when the route cannot be mapped to a controller.
Line 192: Event::run('system.404');
Line 198: Event::run('system.404');
Line 215: Event::run('system.pre_controller');
Line 225: Event::run('system.post_controller_constructor');
Line 236: Event::run('system.404');
Line 252: Event::run('system.post_controller');
Line 526: if ( ! Event::hasRun('system.send_headers'))
Line 528: // Run the send_headers event
Line 529: Event::run('system.send_headers');
Line 564: * Triggers the shutdown of Kohana by closing the output buffer, runs the system.display event.
Line 573: // Run the output event
Line 574: Event::run('system.display', self::$output);
Line 593: // step must be done to prevent gzencode from triggering an error
Line 621: // This header must be sent with compressed content to prevent
Line 868: if ( ! Event::hasRun('system.shutdown'))
Line 871: Event::run('system.shutdown');

/sprout/Helpers/Event_Observer.php   Highlighted file source

Line 22: * Kohana event observer. Uses the SPL observer pattern.
Line 24: abstract class Event_Observer {
Line 32: * @param object Event_Subject
Line 35: public function __construct(Event_Subject $caller)
Line 45: * @param object Event_Subject
Line 48: public function update(Event_Subject $caller)
Line 50: if ( ! ($caller instanceof Event_Subject))
Line 51: throw new Kohana_Exception('event.invalid_subject', get_class($caller), get_class($this));
Line 82: } // End Event Observer

/sprout/Helpers/Event_Subject.php   Highlighted file source

Line 22: * Kohana event subject. Uses the SPL observer pattern.
Line 24: abstract class Event_Subject {
Line 33: * @param object Event_Observer
Line 36: public function attach(Event_Observer $obj)
Line 38: if ( ! ($obj instanceof Event_Observer))
Line 39: throw new Kohana_Exception('eventable.invalid_observer', get_class($obj), get_class($this));
Line 51: * @param object Event_Observer
Line 54: public function detach(Event_Observer $obj)
Line 79: } // End Event Subject

/sprout/Helpers/Needs.php   Highlighted file source

Line 19: use Event;
Line 361: Event::$data = preg_replace ('!<needs\s?/?>!', implode ("\n\t", self::$needs), Event::$data);
Line 364: Event::$data = str_replace ('ROOT/', Kohana::config('core.site_domain'), Event::$data);
Line 365: Event::$data = str_replace ('SITE/', Url::base(TRUE), Event::$data);
Line 366: Event::$data = str_replace ('SKIN/', Kohana::config('core.site_domain') . 'skin/' . SubsiteSelector::$subsite_code . '/', Event::$data);
Line 369: Event::$data = ContentReplace::intlinks(Event::$data);

/sprout/Helpers/RateLimit.php   Highlighted file source

Line 26: * @param string $event The event being done by the user, e.g. 'user-auth-action' or 'form-submit-action'
Line 27: * @param string $user The user who performed the event, may be an empty string for unauthenticated events
Line 29: public static function logHitSuccess($event, $username = '')
Line 31: self::logHit($event, true, $username);
Line 38: * @param string $event The event being done by the user, e.g. 'user-auth-action' or 'form-submit-action'
Line 39: * @param string $user The user who performed the event, may be an empty string for unauthenticated events
Line 41: public static function logHitFailure($event, $username = '')
Line 43: self::logHit($event, false, $username);
Line 50: * @param string $event The event being done by the user, e.g. 'user-auth-action' or 'form-submit-action'
Line 51: * @param bool $success The status of the event, true for success, false for failure
Line 52: * @param string $user The user who performed the event
Line 54: protected static function logHit($event, $success, $username)
Line 58: $data['event'] = trim($event);
Line 69: * @param array $conditions Conditions to match, e.g. 'event', 'success', 'username', 'ip_address' fields
Line 89: * Check that a given event has only been hit by the request ip address an allowable number of times
Line 91: * @param string $event Event to check
Line 92: * @param bool|null $success TRUE to check only successes, FALSE only failures, NULL all events
Line 93: * @param int $limit Maximum number of events
Line 97: public static function checkLimitIP($event, $success, $limit, $time)
Line 100: $conditions = ['event' => $event, 'ip_address' => $ip_address];

/sprout/Helpers/Session.php   Highlighted file source

Line 20: use Event;
Line 92: Event::add('system.shutdown', array($this, 'writeClose'));
Line 207: // Check expiration time to prevent users from manually modifying it
Line 253: // Change the cookie value to match the new session id to prevent "lag"
Line 290: * Runs the system.session_write event, then calls session_write_close.
Line 302: // Run the events that depend on the session being open
Line 303: Event::run('system.session_write');

/sprout/Helpers/Url.php   Highlighted file source

Line 20: use Event;
Line 163: * Sends a page redirect header and runs the system.redirect Event.
Line 171: if (Event::hasRun('system.send_headers'))
Line 220: // Run the redirect event
Line 221: Event::run('system.redirect', $uri);
Line 240: // We are about to exit, so run the send_headers event
Line 241: Event::run('system.send_headers');
Line 244: Event::run('system.shutdown');
Line 284: * This is designed to prevent redirects to other domains, bad pages, etc

/sprout/i18n/en_US/event.php   Highlighted file source

Line 17: 'invalid_subject' => 'Attempt to attach invalid subject %s to %s failed: Subjects must extend the Event_Subject class',
Line 18: 'invalid_observer' => 'Attempt to attach invalid observer %s to %s failed: Observers must extend the Event_Observer class',

/sprout/phpunit_bootstrap.php   Highlighted file source

Line 70: require APPPATH . 'core/Event.php';

A total of 172 lines in 13 files were found