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

Public Member Functions

 __construct ($id, $uid, $type, $tags, $slug, array $fragments, $isBroken)
 
 asHtml ($linkResolver=NULL)
 
 getUrl ($linkResolver=null)
 
 getId ()
 
 getUid ()
 
 asText ()
 
 getType ()
 
 getTags ()
 
 getSlug ()
 
 isBroken ()
 
- Public Member Functions inherited from Prismic\WithFragments
 __construct (array $fragments)
 
 getFragments ()
 
 get ($field)
 
 has ($field)
 
 getAll ($field)
 
 getText ($field)
 
 getNumber ($field, $pattern=null)
 
 getGeoPoint ($field)
 
 getBoolean ($field)
 
 getDate ($field, $pattern=null)
 
 getTimestamp ($field)
 
 getHtml ($field, $linkResolver=null)
 
 getImage ($field)
 
 getAllImages ($field)
 
 getImageView ($field, $view=null)
 
 getAllImageViews ($field, $view)
 
 getStructuredText ($field)
 
 getLink ($field)
 
 getGroup ($field)
 
 getSliceZone ($field)
 
 getEmbed ($field)
 
 getColor ($field)
 
 asHtml ($linkResolver=null)
 

Static Public Member Functions

static parse ($json)
 
- Static Public Member Functions inherited from Prismic\WithFragments
static parseFragment ($json)
 
static parseFragments ($json)
 

Detailed Description

This class embodies a document link; it is what is retrieved from the API when a link is created towards another document in the repository. Do note that in those cases, you do not retrieve all of the linked documents, but only enough information to build your link to the document. For this reason, this is also the class of the object passed in the linkResolver function. LinkInterface objects can be found in two occasions: as the "$link" variable of a HyperlinkSpan object (which happens when the link is a hyperlink in a StructuredText fragment), or the LinkInterface can also be its own fragment (e.g. for a "related" fragment, that links to a related document).

Constructor & Destructor Documentation

§ __construct()

Prismic\Fragment\Link\DocumentLink::__construct (   $id,
  $uid,
  $type,
  $tags,
  $slug,
array  $fragments,
  $isBroken 
)

Constructs a document link.

Parameters
string$idthe ID of the linked document
string$uidthe UID of the linked document (can be null)
string$typethe type of the linked document
array$tagsan array of strings which are the document's tags
string$slugthe current slug of the document
array$fragmentsthe additional fragment data
boolean$isBrokenreturns true if the link is towards a document that is not live, for instance

Member Function Documentation

§ asHtml()

Prismic\Fragment\Link\DocumentLink::asHtml (   $linkResolver = NULL)

Builds an HTML version of the raw link, pointing to the right URL, and with the document's slug as the hypertext. If you want to use one of the document's fragments as the hypertext, you will need to query the document in your controller.

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

Implements Prismic\Fragment\FragmentInterface.

§ asText()

Prismic\Fragment\Link\DocumentLink::asText ( )

Builds an unformatted text version of the raw link: simply, the document's ID.

Returns
string an unformatted text version of the raw link

Implements Prismic\Fragment\FragmentInterface.

§ getId()

Prismic\Fragment\Link\DocumentLink::getId ( )

Returns the ID of the linked document.

Returns
string the ID of the linked document

§ getSlug()

Prismic\Fragment\Link\DocumentLink::getSlug ( )

Returns the current slug of the document

Returns
string the current slug of the document

§ getTags()

Prismic\Fragment\Link\DocumentLink::getTags ( )

Returns an array of strings which are the document's tags

Returns
array an array of strings which are the document's tags

§ getType()

Prismic\Fragment\Link\DocumentLink::getType ( )

Returns the type of the linked document

Returns
string the type of the linked document

§ getUid()

Prismic\Fragment\Link\DocumentLink::getUid ( )

Returns the UID of the linked document.

Returns
string|null the UID of the linked document

§ getUrl()

Prismic\Fragment\Link\DocumentLink::getUrl (   $linkResolver = null)

Returns the URL of the document we're linking to. The linkResolver will be needed in this case, as we're linking to a document link, which should be a URL of your website. Read more about the link resolver at the very end of prismic.io's documentation.

Parameters
\Prismic\LinkResolver$linkResolverthe link resolver (read prismic.io's API documentation to learn more)
Returns
string the URL of the resource we're linking to online

Implements Prismic\Fragment\Link\LinkInterface.

§ isBroken()

Prismic\Fragment\Link\DocumentLink::isBroken ( )

Checks if the link is broken (towards a document that is not live, for instance)

Returns
boolean true if the link is towards a document that is not live, for instance

§ parse()

static Prismic\Fragment\Link\DocumentLink::parse (   $json)
static

Parses a proper bit of unmarshalled JSON into a DocumentLink object. This is used internally during the unmarshalling of API calls.

Parameters
\stdClass$jsonthe raw JSON that needs to be transformed into native objects.
Returns
DocumentLink the new object that was created form the JSON.

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