Prismic.io PHP kit  3.0.0
Public Member Functions | Static Public Member Functions | List of all members
Prismic\Fragment\Group Class Reference
Inheritance diagram for Prismic\Fragment\Group:
Prismic\Fragment\FragmentInterface

Public Member Functions

 __construct ($array)
 
 asHtml ($linkResolver=null)
 
 asText ()
 
 getArray ()
 

Static Public Member Functions

static parseSubfragmentList ($json)
 
static parse ($json)
 

Detailed Description

This class embodies a Group fragment. To understand better how it works: each group contains several sets of subfragments (as many as the content writer saw fit). So, once you have your group, you have two layers to go through: getting the set of subfragments you need (or, most often, looping through all of them); then picking which subfragment from its name, as defined in the JSON mask for this fragment.

For instance: for($groupFragment->getArray() as $groupDoc) { echo $groupDoc.getText('subfragmentName'); }

Each group doc can be manipulated like a regular Document.

Constructor & Destructor Documentation

§ __construct()

Prismic\Fragment\Group::__construct (   $array)

Constructs a group fragment.

Parameters
string$arraythe array of associative arrays of subfragments

Member Function Documentation

§ asHtml()

Prismic\Fragment\Group::asHtml (   $linkResolver = null)

Builds a HTML version of the Group fragment.

Parameters
\Prismic\LinkResolver$linkResolverthe link resolver
Returns
string the HTML version of the Group fragment

Implements Prismic\Fragment\FragmentInterface.

§ asText()

Prismic\Fragment\Group::asText ( )

Builds a text version of the Group fragment.

Returns
string the text version of the Group fragment

Implements Prismic\Fragment\FragmentInterface.

§ getArray()

Prismic\Fragment\Group::getArray ( )

Returns an array version of this group fragment, on which you can do all you can do on an array: loop, access a certain index, ...

Each item is an associative array of subfragments.

Returns
array the array to loop on / access items / etc.

§ parse()

static Prismic\Fragment\Group::parse (   $json)
static

Parses a given Group fragment. Not meant to be used except for testing.

Parameters
\stdClass$jsonthe json bit retrieved from the API that represents a Group fragment.
Returns
the manipulable object for that Group fragment.

§ parseSubfragmentList()

static Prismic\Fragment\Group::parseSubfragmentList (   $json)
static

Parses a list of subfragments, and makes it into an associative array of fragments. Not meant to be used except for testing.

Parameters
\stdClass$jsonthe json bit retrieved from the API that represents the list of subfragments
Returns
array the array of subfragments

The documentation for this class was generated from the following file: