CaptionDescriptor
in package
implements
JsonSerializable
Caption descriptor for media components.
Used for Photo, Gallery, Mosaic, and other media components to provide rich captions with formatting and interactivity.
Tags
Table of Contents
Interfaces
- JsonSerializable
Constants
- FORMAT_HTML = 'html'
- Valid format types.
- FORMAT_MARKDOWN = 'markdown'
- FORMAT_NONE = 'none'
Properties
- $additions : array<int, AdditionInterface>|null
- Additions (links, etc.).
- $format : string|null
- The text format.
- $inlineTextStyles : array<int, array<string, mixed>>|null
- Inline text styles.
- $text : string
- $textStyle : string|null
- The text style reference.
Methods
- __construct() : mixed
- Create a new CaptionDescriptor.
- addAddition() : $this
- Add an addition.
- addInlineTextStyle() : $this
- Add an inline text style.
- html() : self
- Create an HTML caption.
- jsonSerialize() : array<string, mixed>
- {@inheritdoc}
- markdown() : self
- Create a Markdown caption.
- plain() : self
- Create a plain text caption.
- setAdditions() : $this
- Set additions.
- setFormat() : $this
- Set the text format.
- setInlineTextStyles() : $this
- Set inline text styles.
- setTextStyle() : $this
- Set the text style reference.
Constants
FORMAT_HTML
Valid format types.
public
mixed
FORMAT_HTML
= 'html'
FORMAT_MARKDOWN
public
mixed
FORMAT_MARKDOWN
= 'markdown'
FORMAT_NONE
public
mixed
FORMAT_NONE
= 'none'
Properties
$additions
Additions (links, etc.).
private
array<int, AdditionInterface>|null
$additions
= null
$format
The text format.
private
string|null
$format
= null
$inlineTextStyles
Inline text styles.
private
array<int, array<string, mixed>>|null
$inlineTextStyles
= null
$text read-only
private
string
$text
$textStyle
The text style reference.
private
string|null
$textStyle
= null
Methods
__construct()
Create a new CaptionDescriptor.
public
__construct(string $text) : mixed
Parameters
- $text : string
-
The caption text.
addAddition()
Add an addition.
public
addAddition(AdditionInterface $addition) : $this
Parameters
- $addition : AdditionInterface
-
The addition.
Return values
$thisaddInlineTextStyle()
Add an inline text style.
public
addInlineTextStyle(int $rangeStart, int $rangeLength, string|array<string, mixed> $textStyle) : $this
Parameters
- $rangeStart : int
-
The starting position.
- $rangeLength : int
-
The length.
- $textStyle : string|array<string, mixed>
-
The text style name or inline definition.
Return values
$thishtml()
Create an HTML caption.
public
static html(string $html) : self
Parameters
- $html : string
-
The HTML caption.
Return values
self —A new instance.
jsonSerialize()
{@inheritdoc}
public
jsonSerialize() : array<string, mixed>
Return values
array<string, mixed>markdown()
Create a Markdown caption.
public
static markdown(string $markdown) : self
Parameters
- $markdown : string
-
The Markdown caption.
Return values
self —A new instance.
plain()
Create a plain text caption.
public
static plain(string $text) : self
Parameters
- $text : string
-
The caption text.
Return values
self —A new instance.
setAdditions()
Set additions.
public
setAdditions(array<int, AdditionInterface> $additions) : $this
Parameters
- $additions : array<int, AdditionInterface>
-
The additions.
Return values
$thissetFormat()
Set the text format.
public
setFormat(string $format) : $this
Parameters
- $format : string
-
One of 'html', 'markdown', 'none'.
Return values
$thissetInlineTextStyles()
Set inline text styles.
public
setInlineTextStyles(array<int, array<string, mixed>> $styles) : $this
Parameters
- $styles : array<int, array<string, mixed>>
-
The inline styles.
Return values
$thissetTextStyle()
Set the text style reference.
public
setTextStyle(string $textStyle) : $this
Parameters
- $textStyle : string
-
The text style name.