Apple News API PHP Client

DataTable extends Component
in package

FinalYes

DataTable component for structured tabular data.

The datatable component displays data in a sortable, interactive table format. It supports rich data types and automatic formatting.

Tags
see
https://developer.apple.com/documentation/apple_news/datatable

Table of Contents

Properties

$anchor  : string|null
$animation  : array<string, mixed>|null
$behavior  : array<string, mixed>|null
$conditional  : array<string, mixed>|null
$hidden  : bool
$identifier  : string|null
$layout  : string|null
$style  : string|null
$data  : array<string, mixed>|null
The table data descriptor.
$dataTableStyle  : string|null
The table style reference.
$showDescriptorLabels  : bool|null
Whether to show the header row.
$sortBy  : array<int, array{descriptor: string, direction: string}>|null
The sort order for data.

Methods

addSortBy()  : $this
Add a sort descriptor.
getRole()  : string
Get the role name for the component (e.g., 'body', 'photo', 'heading1').
jsonSerialize()  : array<string, mixed>
Implementation of JsonSerializable.
setAnchor()  : static
Set the anchor configuration.
setAnimation()  : static
Set component animation using an array.
setAnimationObject()  : static
Set the component animation using a typed Animation object.
setBehavior()  : static
Set the component behavior using an array.
setBehaviorObject()  : static
Set the component behavior using a typed Behavior object.
setConditional()  : static
Set conditional properties for the component.
setData()  : $this
Set the table data.
setDataTableStyle()  : $this
Set the table style reference.
setHidden()  : static
Set whether the component is hidden.
setIdentifier()  : static
Set a unique identifier for this component.
setLayout()  : static
Set the layout name or inline layout.
setShowDescriptorLabels()  : $this
Set whether to show descriptor labels (header row).
setSortBy()  : $this
Set the sort order for the data.
setStyle()  : static
Set the style name.
getBaseProperties()  : array<string, mixed>
Get the base properties common to all components for JSON serialization.

Properties

$anchor

protected string|null $anchor = null

Anchor configuration for pinning components.

$animation

protected array<string, mixed>|null $animation = null

Animation settings for the component.

$behavior

protected array<string, mixed>|null $behavior = null

Behavior settings (e.g., Parallax).

$conditional

protected array<string, mixed>|null $conditional = null

Conditional properties based on orientation/device.

$hidden

protected bool $hidden = false

Whether the component is hidden by default.

$identifier

protected string|null $identifier = null

A unique identifier for this component instance.

$layout

protected string|null $layout = null

Reference to a named layout defined in Article.

$style

protected string|null $style = null

Reference to a named style defined in Article.

$data

The table data descriptor.

private array<string, mixed>|null $data = null

$dataTableStyle

The table style reference.

private string|null $dataTableStyle = null

$showDescriptorLabels

Whether to show the header row.

private bool|null $showDescriptorLabels = null

$sortBy

The sort order for data.

private array<int, array{descriptor: string, direction: string}>|null $sortBy = null

Methods

addSortBy()

Add a sort descriptor.

public addSortBy(string $descriptor[, string $direction = 'ascending' ]) : $this
Parameters
$descriptor : string

The descriptor identifier to sort by.

$direction : string = 'ascending'

The sort direction ('ascending' or 'descending').

Return values
$this

getRole()

Get the role name for the component (e.g., 'body', 'photo', 'heading1').

public getRole() : string
Return values
string

jsonSerialize()

Implementation of JsonSerializable.

public jsonSerialize() : array<string, mixed>
Return values
array<string, mixed>

setAnchor()

Set the anchor configuration.

public setAnchor(string $anchor) : static
Parameters
$anchor : string

The anchor configuration.

Return values
static

setAnimationObject()

Set the component animation using a typed Animation object.

public setAnimationObject(AnimationInterface $animation) : static

This method provides type-safe animation configuration:

$photo->setAnimationObject(FadeInAnimation::fromTransparent());
$body->setAnimationObject(MoveInAnimation::fromLeft());
Parameters
$animation : AnimationInterface

The animation object.

Return values
static

setBehaviorObject()

Set the component behavior using a typed Behavior object.

public setBehaviorObject(BehaviorInterface $behavior) : static

This method provides type-safe behavior configuration:

$photo->setBehaviorObject(Parallax::withFactor(0.8));
$photo->setBehaviorObject(new Springy());
Parameters
$behavior : BehaviorInterface

The behavior object.

Return values
static

setData()

Set the table data.

public setData(array<string, mixed> $data) : $this

The data array should follow the Apple News data descriptor format with 'descriptors' and 'records' keys.

Parameters
$data : array<string, mixed>

The table data.

Return values
$this

setDataTableStyle()

Set the table style reference.

public setDataTableStyle(string $style) : $this
Parameters
$style : string

The style name.

Return values
$this

setHidden()

Set whether the component is hidden.

public setHidden(bool $hidden) : static
Parameters
$hidden : bool

Whether to hide the component.

Return values
static

setIdentifier()

Set a unique identifier for this component.

public setIdentifier(string $identifier) : static
Parameters
$identifier : string

The unique identifier.

Return values
static

setLayout()

Set the layout name or inline layout.

public setLayout(string $layout) : static
Parameters
$layout : string

Reference to a name in componentLayouts.

Return values
static

setShowDescriptorLabels()

Set whether to show descriptor labels (header row).

public setShowDescriptorLabels(bool $show) : $this
Parameters
$show : bool

Whether to show labels.

Return values
$this

setSortBy()

Set the sort order for the data.

public setSortBy(array<int, array{descriptor: string, direction: string}> $sortBy) : $this
Parameters
$sortBy : array<int, array{descriptor: string, direction: string}>

Sort configuration.

Return values
$this

setStyle()

Set the style name.

public setStyle(string $style) : static
Parameters
$style : string

Reference to a name in componentStyles.

Return values
static

getBaseProperties()

Get the base properties common to all components for JSON serialization.

protected getBaseProperties() : array<string, mixed>
Return values
array<string, mixed>

        
On this page

Search results