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

Public Member Functions

 __construct ($blocks)
 
 getBlocks ()
 
 asText ()
 
 getFirstPreformatted ()
 
 getPreformatted ()
 
 getFirstParagraph ()
 
 getParagraphs ()
 
 getFirstImage ()
 
 getImages ()
 
 getFirstHeading ()
 
 getHeadings ()
 
 asHtml ($linkResolver=null, $htmlSerializer=null)
 
- Public Member Functions inherited from Prismic\Fragment\FragmentInterface
 asHtml ($linkResolver)
 

Static Public Member Functions

static asHtmlBlock ($block, $linkResolver=null, $htmlSerializer=null)
 
static insertSpans ($text, array $spans, $linkResolver=null, $htmlSerializer=null)
 
static parseSpan ($json)
 
static parseText ($json)
 
static parseBlock ($json)
 
static parse ($json)
 
static extractLink ($data)
 

Detailed Description

This class embodies a StructuredText fragment.

Technically, a StructuredText fragment is not much more than an array of blocks, but there are many things to do with this fragment, including in the HTML serialization, but not only. It is arguably the most powerful and manipulable way any CMS stores structured text nowadays.

Constructor & Destructor Documentation

§ __construct()

Prismic\Fragment\StructuredText::__construct (   $blocks)

Constructs a StructuredText object.

Parameters
array$blocksthe array of objects

Member Function Documentation

§ asHtml()

Prismic\Fragment\StructuredText::asHtml (   $linkResolver = null,
  $htmlSerializer = null 
)

Builds a HTML version of the StructuredText fragment.

Parameters
\Prismic\LinkResolver$linkResolverthe link resolver
lambda$htmlSerializeran optional function to generate custom HTML code
Returns
string the HTML version of the StructuredText fragment

§ asHtmlBlock()

static Prismic\Fragment\StructuredText::asHtmlBlock (   $block,
  $linkResolver = null,
  $htmlSerializer = null 
)
static

Transforms a block into HTML (for internal use)

Parameters
\Prismic\Fragment\Block\BlockInterface$blocka given block
\Prismic\LinkResolver$linkResolverthe link resolver
lambda$htmlSerializer
Returns
string the HTML version of the block

§ asText()

Prismic\Fragment\StructuredText::asText ( )

Builds a text version of the StructuredText fragment.

Returns
string the text version of the StructuredText fragment

Implements Prismic\Fragment\FragmentInterface.

§ extractLink()

static Prismic\Fragment\StructuredText::extractLink (   $data)
static

Parses and extracts a link of absolutely any kind.

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

§ getBlocks()

Prismic\Fragment\StructuredText::getBlocks ( )

Returns the array of blocks.

Returns
array the array of objects

§ getFirstHeading()

Prismic\Fragment\StructuredText::getFirstHeading ( )

Returns the first heading block in the StructuredText fragment.

Returns
the first heading block in the StructuredText fragment

§ getFirstImage()

Prismic\Fragment\StructuredText::getFirstImage ( )

Returns the first image block in the StructuredText fragment.

Returns
the first image block in the StructuredText fragment

§ getFirstParagraph()

Prismic\Fragment\StructuredText::getFirstParagraph ( )

Returns the first paragraph block in the StructuredText fragment.

Returns
the first paragraph block in the StructuredText fragment

§ getFirstPreformatted()

Prismic\Fragment\StructuredText::getFirstPreformatted ( )

Returns the first preformatted block in the StructuredText fragment.

Returns
the first preformatted block in the StructuredText fragment

§ getHeadings()

Prismic\Fragment\StructuredText::getHeadings ( )

Returns an array of all heading blocks in the StructuredText fragment, as objects.

Returns
array all heading blocks in the StructuredText fragment

§ getImages()

Prismic\Fragment\StructuredText::getImages ( )

Returns an array of all image blocks in the StructuredText fragment, as objects.

Returns
array all image blocks in the StructuredText fragment

§ getParagraphs()

Prismic\Fragment\StructuredText::getParagraphs ( )

Returns an array of all paragraph blocks in the StructuredText fragment, as objects.

Returns
array all paragraph blocks in the StructuredText fragment

§ getPreformatted()

Prismic\Fragment\StructuredText::getPreformatted ( )

Returns an array of all preformatted blocks in the StructuredText fragment, as objects.

Returns
array all preformatted blocks in the StructuredText fragment

§ insertSpans()

static Prismic\Fragment\StructuredText::insertSpans (   $text,
array  $spans,
  $linkResolver = null,
  $htmlSerializer = null 
)
static

Transforms a text block into HTML (for internal use)

Parameters
string$textthe raw text of the block
array$spansthe spans of the block, as an array of objects
\Prismic\LinkResolver$linkResolverthe link resolver
Returns
string the HTML version of the block

§ parse()

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

Parses a given StructuredText fragment (for internal use)

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

§ parseBlock()

static Prismic\Fragment\StructuredText::parseBlock (   $json)
static

Parses a given block (for internal use)

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

§ parseSpan()

static Prismic\Fragment\StructuredText::parseSpan (   $json)
static

Parses a given span (for internal use)

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

§ parseText()

static Prismic\Fragment\StructuredText::parseText (   $json)
static

Parses a given text block (for internal use)

Parameters
\stdClass$jsonthe json bit retrieved from the API that represents a text block.
Returns
the parsed information for that text block.

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