| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
class AkActionWebServiceServer extends AkObject |
|---|
| 20 |
{ |
|---|
| 21 |
var $_available_drivers = array('xml_rpc'); |
|---|
| 22 |
var $_Server; |
|---|
| 23 |
var $_services = array(); |
|---|
| 24 |
|
|---|
| 25 |
function __construct($server_driver) |
|---|
| 26 |
{ |
|---|
| 27 |
$server_driver = AkInflector::underscore($server_driver); |
|---|
| 28 |
if(in_array($server_driver, $this->_available_drivers)){ |
|---|
| 29 |
$server_class_name = 'Ak'.AkInflector::camelize($server_driver).'Server'; |
|---|
| 30 |
require_once(AK_LIB_DIR.DS.'AkActionWebService'.DS.'Servers'.DS.$server_class_name.'.php'); |
|---|
| 31 |
|
|---|
| 32 |
$this->_Server =& new $server_class_name($this); |
|---|
| 33 |
|
|---|
| 34 |
}else { |
|---|
| 35 |
trigger_error(Ak::t('Invalid Web Service driver provided. Available Drivers are: %drivers', array('%drivers'=>join(', ',$this->_available_drivers))), E_USER_WARNING); |
|---|
| 36 |
} |
|---|
| 37 |
} |
|---|
| 38 |
|
|---|
| 39 |
function addService($service) |
|---|
| 40 |
{ |
|---|
| 41 |
$service_file = AkInflector::underscore($service); |
|---|
| 42 |
if(substr($service_file,-8) != '_service'){ |
|---|
| 43 |
$service_file = $service_file.'_service'; |
|---|
| 44 |
} |
|---|
| 45 |
$service_model = AkInflector::camelize($service_file); |
|---|
| 46 |
$service_name_space = substr($service_file,0,-8); |
|---|
| 47 |
|
|---|
| 48 |
if(empty($this->_services[$service_name_space])){ |
|---|
| 49 |
|
|---|
| 50 |
require_once(AK_MODELS_DIR.DS.$service_file.'.php'); |
|---|
| 51 |
|
|---|
| 52 |
if(!class_exists($service_model)){ |
|---|
| 53 |
trigger_error(Ak::t('Could not find class for the service %service at %models_dir', array('%service'=>$service_model, '%models_dir' => AK_MODELS_DIR), E_USER_ERROR)); |
|---|
| 54 |
return false; |
|---|
| 55 |
} |
|---|
| 56 |
$this->_services[$service_name_space] =& new $service_model(); |
|---|
| 57 |
} |
|---|
| 58 |
} |
|---|
| 59 |
|
|---|
| 60 |
function init() |
|---|
| 61 |
{ |
|---|
| 62 |
if(method_exists($this->_Server, 'init')){ |
|---|
| 63 |
$args = func_get_args(); |
|---|
| 64 |
call_user_func_array(array(&$this->_Server, 'init'), $args); |
|---|
| 65 |
} |
|---|
| 66 |
} |
|---|
| 67 |
|
|---|
| 68 |
function serve() |
|---|
| 69 |
{ |
|---|
| 70 |
$this->_Server->serve(); |
|---|
| 71 |
} |
|---|
| 72 |
} |
|---|
| 73 |
|
|---|
| 74 |
?> |
|---|