示例#1
0
Settings::setProtected('auth', $auth);
// Initialize database
// --------------------------------------------------
$dbengine = Settings::getProtected('db');
require_once "../modules/db/{$dbengine}/Db{$dbengine}.class.php";
// Load the appropriate database engine class
$dbClass = "Db{$dbengine}";
$db = new $dbClass();
$dbsettings = Settings::getProtected('database');
$db->create($dbsettings['host'], $dbsettings['username'], $dbsettings['password'], $dbsettings['database']);
// Save it to the settings manager
Settings::setProtected('db', $db);
// Initialize dispatcher
// --------------------------------------------------
$dispatch = new Dispatch();
$dispatch->register(array('DispatchController', 'getNextAvailableItem'));
Settings::setProtected('dispatch', $dispatch);
// Initialize event manager
// --------------------------------------------------
$eventManager = new EventManager();
Settings::setProtected('eventManager', $eventManager);
// Initialize transcript controller
// --------------------------------------------------
Transcript::setEventManager($eventManager);
Transcript::register('load', array('TranscriptController', 'load'));
Transcript::register('save', array('TranscriptController', 'save'));
Transcript::register('diff', array('TranscriptController', 'diff'));
// Initialize workflow controller
// --------------------------------------------------
Workflow::register('callback', array('WorkflowController', 'parse'));
// Initialize notifications controller
示例#2
0
    public function getNextColor()
    {
        $color = array_pop($this->colors);
        return $color;
    }
}
$colors = new Colors();
// Get next available item function
function getNextAvailable($params)
{
    global $colors;
    return $colors->getNextColor();
}
// Test code
$dispatch = new Dispatch();
$dispatch->register('getNextAvailable');
$dispatch->init(array('colors' => $colors));
echo "Getting next item: ";
$color = $dispatch->next();
echo $color ? $color : 'end of list';
echo "\nGetting next item: ";
$color = $dispatch->next();
echo $color ? $color : 'end of list';
echo "\nGetting next item: ";
$color = $dispatch->next();
echo $color ? $color : 'end of list';
echo "\nGetting next item: ";
$color = $dispatch->next();
echo $color ? $color : 'end of list';
echo "\nGetting next item: ";
$color = $dispatch->next();