Skip to content

Instantly share code, notes, and snippets.

@norv
Created November 9, 2012 20:15
Show Gist options
  • Save norv/4047952 to your computer and use it in GitHub Desktop.
Save norv/4047952 to your computer and use it in GitHub Desktop.
<?php
class BreezeDispatcher
{
/**
* Used in:
* 'integrate_actions' => 'BreezeDispatcher::actions'
*
* @param array $actions
*/
static function actions(&$actions)
{
/* A whole new action just for some ajax calls... */
$actions['breezeajax'] = array(Breeze::$folder .'BreezeDispatcher.php', 'BreezeDispatcher::dispatch');
/* The general wall */
$actions['wall'] = array(Breeze::$folder .'BreezeDispatcher.php', 'BreezeDispatcher::dispatch');
/* Replace the buddy action */
$actions['buddy'] = array(Breeze::$folder .'BreezeDispatcher.php', 'BreezeDispatcher::dispatch');
/* A special action for the buddy request message */
$actions['breezebuddyrequest'] = array(Breeze::$folder .'BreezeDispatcher.php', 'BreezeDispatcher::dispatch');
}
static function dispatch()
{
// Lets do everything as if SMF didn't do anything for us.
$actions = array(
'breezeajax' => array ('BreezeAjax.php', 'BreezeAjax' , 'call'),
'wall' => array ('BreezeGeneral.php', 'BreezeGeneral', 'call'),
'buddy' => array ('BreezeBuddy.php', 'BreezeBuddy', 'buddy'),
'breezebuddyrequest' => array ('BreezeUser.php', 'BreezeUser', 'BuddyMessageSend'),
);
if (isset($_GET['action']) && in_array($_GET['action'], array_keys($actions)))
{
require_once (Breeze::$folder . $actions[$_GET['action']][0]);
$controller_name = $actions[$_GET['action']][1];
$controller = new $controller_name();
// and there, lets go
$method_name = $actions[$_GET['action']][2];
$controller->{$method_name}();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment