/** * Parses a proper bit of unmarshaled JSON into a DocumentLink object. * This is used internally during the unmarshaling of API calls. * * @param \stdClass $json the raw JSON that needs to be transformed into native objects. * * @return DocumentLink the new object that was created form the JSON. */ public static function parse($json) { $uid = isset($json->document->uid) ? $json->document->uid : null; $fragments = isset($json->document->data) ? WithFragments::parseFragments($json->document->data) : array(); return new DocumentLink($json->document->id, $uid, $json->document->type, isset($json->document->{'tags'}) ? $json->document->tags : null, $json->document->slug, $fragments, $json->isBroken); }
/** * Parses a given document. Not meant to be used except for testing. * * @param \stdClass $json the json bit retrieved from the API that represents a document. * @return \Prismic\Document the manipulable object for that document. */ public static function parse(\stdClass $json) { $uid = isset($json->uid) ? $json->uid : null; $fragments = WithFragments::parseFragments($json->data); $slugs = array(); foreach ($json->slugs as $slug) { $slugs[] = urldecode($slug); } return new Document($json->id, $uid, $json->type, $json->href, $json->tags, $slugs, $fragments); }