Skip to content

Instantly share code, notes, and snippets.

@MihailoJoksimovic
Created August 5, 2013 21:12
Show Gist options
  • Save MihailoJoksimovic/6159666 to your computer and use it in GitHub Desktop.
Save MihailoJoksimovic/6159666 to your computer and use it in GitHub Desktop.
/**
* Attach a class to a server
*
* Accepts a class name to use when handling requests. Any additional
* arguments will be passed to that class' constructor when instantiated.
*
* See {@link setObject()} to set pre-configured object instances as request handlers.
*
* @param string|object $class Class name or object instance which executes
* SOAP Requests at endpoint.
* @param string $namespace
* @param null|array $argv
* @return self
* @throws Exception\InvalidArgumentException if called more than once, or if class does not exist
*/
public function setClass($class, $namespace = '', $argv = null)
{
if (isset($this->class)) {
throw new Exception\InvalidArgumentException('A class has already been registered with this soap server instance');
}
if (is_object($class)) {
return $this->setObject($class);
}
if (!is_string($class)) {
throw new Exception\InvalidArgumentException(sprintf(
'Invalid class argument (%s)',
gettype($class)
));
}
if (!class_exists($class)) {
throw new Exception\InvalidArgumentException(sprintf(
'Class "%s" does not exist',
$class
));
}
$this->class = $class;
if (2 < func_num_args()) {
$argv = func_get_args();
$this->classArgs = array_slice($argv, 2);
}
return $this;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment