<?php require_once "global.func.php"; require_once "dispatch.php"; require_once "control.php"; require_once "model.php"; require_once "dao.php"; Dispatch::init(); Dispatch::start();
{ $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(); echo $color ? $color : 'end of list';