27 foreach ( explode(
',', substr( $definition, $pos + 1, - 1 ) ) as $t_param ) {
34 [$ret[
'out'], $ret[
'name']] = explode(
' ', substr( $definition, 0, $pos ) );
59 public $mClassName =
'XCube_Service';
70 public $_mFunctions = [];
72 public function __construct() {
75 public function prepare() {
78 public function addType( $className ) {
79 $this->_mTypes[] = $className;
82 public function addFunction() {
83 $args = func_get_args();
88 $this->_addFunctionStandard( $arg0, $args[1], $args[2] );
89 } elseif ( 1 === $n && is_array( $arg0 ) ) {
90 $this->_addFunctionStandard( $arg0[
'name'], $arg0[
'in'], $arg0[
'out'] );
94 public function _addFunctionStandard( $name, $in, $out ) {
95 $this->_mFunctions[ $name ] = [
109 public function register( $name, &$procedure ) {
122 public $mClientErrorStr;
126 public function __construct( &$service ) {
127 $this->mService =& $service;
130 public function prepare() {
133 public function setUser( &$user ) {
134 $this->mUser =& $user;
137 public function call( $operation, $params ) {
140 public function getOperationData( $operation ) {
143 public function setError( $message ) {
144 $this->mClientErrorStr = $message;
147 public function getError() {
148 return ! empty( $this->mClientErrorStr ) ? $this->mClientErrorStr : $this->mService->mErrorStr;
162 public function call( $operation, $params ) {
163 $this->mClientErrorStr =
null;
165 if ( ! is_object( $this->mService ) ) {
166 $this->mClientErrorStr =
'This instance is not connected to service';
171 $root =& XCube_Root::getSingleton();
172 $request_bak =& $root->mContext->mRequest;
173 unset( $root->mContext->mRequest );
177 if ( isset( $this->mService->_mFunctions[ $operation ] ) ) {
178 $ret = call_user_func( [ $this->mService, $operation ] );
180 unset( $root->mContext->mRequest );
181 $root->mContext->mRequest =& $request_bak;
186 $this->mClientErrorStr =
"operation {$operation} not present.";