Recurly_Base::__parseResponseToNewObject PHP Méthode

__parseResponseToNewObject() protected static méthode

Use a valid Recurly_Response to populate a new object.
protected static __parseResponseToNewObject ( $response, $uri, $client )
    protected static function __parseResponseToNewObject($response, $uri, $client)
    {
        $dom = new DOMDocument();
        if (empty($response->body) || !$dom->loadXML($response->body, LIBXML_NOBLANKS)) {
            return null;
        }
        $rootNode = $dom->documentElement;
        $obj = Recurly_Resource::__createNodeObject($rootNode);
        $obj->_client = $client;
        Recurly_Resource::__parseXmlToObject($rootNode->firstChild, $obj);
        if ($obj instanceof self) {
            $obj->_afterParseResponse($response, $uri);
        }
        return $obj;
    }

Usage Example

Exemple #1
0
 /**
  * Delete the URI, validate the response and return the object.
  * @param string Resource URI, if not fully qualified, the base URL will be appended
  * @param string Optional client for the request, useful for mocking the client
  */
 protected static function _delete($uri, $client = null)
 {
     if (is_null($client)) {
         $client = new Recurly_Client();
     }
     $response = $client->request(Recurly_Client::DELETE, $uri);
     $response->assertValidResponse();
     if ($response->body) {
         return Recurly_Base::__parseResponseToNewObject($response, $uri, $client);
     }
     return null;
 }