public function __construct(Request $request, array $member_id) { self::$_request = $request; self::$config = (include ST_DIR . '/config.php'); self::$_routing = (include ST_DIR . '/routing.php'); self::$_user = (object) $member_id; $this->_tpl = $tpl; if (empty($this->_user->user_id)) { self::$_user->user_id = 0; self::$_user->user_group = 5; } self::$_user->ip_address = $_SERVER['REMOTE_ADDR']; $this->eventManager = Events::getInstance(); $this->addToBreadcrumbs($GLOBALS['config']['home_title'], $GLOBALS['config']['http_home_url']); $this->configure(); }
/** * Sorts registered events by priority * @return void */ protected static function sortByPriority() { $ce = Events::getInstance(); foreach(array_keys($ce->registeredEvents) as $event) { usort($ce->registeredEvents[$event],'Events::comparePriority'); } }
/** * An internal function used by Concrete to "fire" a system-wide event. Any time this happens, events that * a developer has hooked into will be run. * @param string $event * @return void */ public static function fire($event) { if (!defined('ENABLE_APPLICATION_EVENTS') || ENABLE_APPLICATION_EVENTS == false) { return; } // any additional arguments passed to the fire function will get passed FIRST to the method, with the method's own registered // params coming at the end. e.g. if I fire Events::fire('on_login', $userObject) it will come in with user object first $args = func_get_args(); if (count($args) > 1) { array_shift($args); } else { $args = false; } $ce = Events::getInstance(); $events = $ce->registeredEvents[$event]; $eventReturn = false; if (is_array($events)) { foreach ($events as $ev) { $type = $ev[0]; $proceed = true; if ($type == Events::EVENT_TYPE_PAGETYPE) { // then the first argument in the event fire() method will be the page // that this applies to. We check to see if the page type is the right type $proceed = false; if (is_object($args[0]) && $args[0] instanceof Page && $args[0]->getCollectionTypeID() > 0) { if ($ev[3] == Loader::pageTypeControllerPath($args[0]->getCollectionTypeHandle())) { $proceed = true; } } } if ($proceed) { if ($ev[3] != false) { // HACK - second part is for windows and its paths if (substr($ev[3], 0, 1) == '/' || substr($ev[3], 1, 1) == ':') { // then this means that our path is a full one require_once $ev[3]; } else { require_once DIR_BASE . '/' . $ev[3]; } } $params = is_array($ev[4]) ? $ev[4] : array(); // now if args has any values we put them FIRST $params = array_merge($args, $params); if (method_exists($ev[1], $ev[2])) { // Note: DO NOT DO RETURN HERE BECAUSE THEN MULTIPLE EVENTS WON'T WORK $eventReturn = call_user_func_array(array($ev[1], $ev[2]), $params); } } } } return $eventReturn; }
/** * Test to see if getInstance returns a Events class instance */ public function testGetInstance() { $events = Events::getInstance(); $this->assertInstanceOf('Concrete5_Library_Events', $events); }