/** * Client constructor * * @param Repository $config */ public function __construct(Repository $config) { // Get the config data $this->config = $config; // Make the client instance $this->client = new Client($this->config->get('plesk.host')); $this->client->setCredentials($this->config->get('plesk.login'), $this->config->get('plesk.password')); }
/** * Perform plain API request * * @param string|array $request * @param int $mode * @return XmlResponse */ public function request($request, $mode = Client::RESPONSE_SHORT) { $wrapperTag = $this->_wrapperTag; if (is_array($request)) { $request = [$wrapperTag => $request]; } else { if (preg_match('/^[a-z]/', $request)) { $request = "{$wrapperTag}.{$request}"; } else { $request = "<{$wrapperTag}>{$request}</{$wrapperTag}>"; } } return $this->_client->request($request, $mode); }
/** * Perform plain API request * * @param string|array $request * @param int $mode * @return XmlResponse */ public function request($request, $mode = Client::RESPONSE_SHORT) { $wrapperTag = $this->_wrapperTag; if (is_null($wrapperTag)) { $classNameParts = explode('\\', get_class($this)); $wrapperTag = end($classNameParts); $wrapperTag = strtolower(preg_replace('/([a-z])([A-Z])/', '\\1-\\2', $wrapperTag)); } if (is_array($request)) { $request = [$wrapperTag => $request]; } else { if (preg_match('/^[a-z]/', $request)) { $request = "{$wrapperTag}.{$request}"; } else { $request = "<{$wrapperTag}>{$request}</{$wrapperTag}>"; } } return $this->_client->request($request, $mode); }