Exemple #1
0
 /**
  * Parses a given SliceZone fragment. Not meant to be used except for testing.
  *
  * @param  \stdClass                $json the json bit retrieved from the API that represents a SliceZone fragment.
  * @return \Prismic\Fragment\SliceZone  the manipulable object for that SliceZone fragment.
  */
 public static function parse($json)
 {
     $slices = array();
     foreach ($json as $slicejson) {
         if (property_exists($slicejson, "slice_type") && property_exists($slicejson, "slice_type")) {
             if (property_exists($slicejson, "slice_label")) {
                 $label = $slicejson->slice_label;
             } else {
                 $label = null;
             }
             array_push($slices, new Slice($slicejson->slice_type, $label, WithFragments::parseFragment($slicejson->value)));
         }
     }
     return new SliceZone($slices);
 }
Exemple #2
0
 /**
  * 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);
 }
Exemple #3
0
 /**
  * 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);
 }