LiveContainer
extends Container
in package
Live Coverage container component.
The live_container component holds the live_post updates of a Live Coverage article and displays them in real time. It may only contain LivePost components and needs an identifier unique within the article.
Apple must enable Live Coverage for the channel. Publish the article with ArticleMetadata::setLiveCoverageState(LiveCoverageState::LIVE).
Usage:
$live = (new LiveContainer('live-coverage'))
->addComponent(
(new LivePost('post-2'))
->addComponent(new Body('Updated at 13:50'))
->addComponent(new Body('Latest update text.'))
);
Table of Contents
Properties
- $anchor : string|null
- $animation : array<string, mixed>|null
- $behavior : array<string, mixed>|null
- $components : array<string|int, Component>
- $conditional : array<string, mixed>|null
- $contentDisplay : string|array<string, mixed>|null
- $hidden : bool
- $identifier : string|null
- $layout : string|null
- $style : string|null
Methods
- __construct() : mixed
- Create a new LiveContainer component.
- addComponent() : self
- Add a live post to this container.
- getComponents() : array<int, Component>
- Get the child components, in the order they were added.
- getRole() : string
- Get the role name for the component (e.g., 'body', 'photo', 'heading1').
- getStyle() : string|null
- Get the component style name.
- 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.
- setContentDisplay() : $this
- Set the content display mode using a string or array.
- setContentDisplayObject() : $this
- Set the content display mode using a typed ContentDisplay object.
- setHidden() : static
- Set whether the component is hidden.
- setIdentifier() : static
- Set the identifier for this container.
- setLayout() : static
- Set the layout name or inline layout.
- 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).
$components
protected
array<string|int, Component>
$components
= []
Child components.
$conditional
protected
array<string, mixed>|null
$conditional
= null
Conditional properties based on orientation/device.
$contentDisplay
protected
string|array<string, mixed>|null
$contentDisplay
= null
Layout mode for child components.
$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.
Methods
__construct()
Create a new LiveContainer component.
public
__construct(string $identifier) : mixed
Parameters
- $identifier : string
-
Identifier for the container, unique across the article.
Tags
addComponent()
Add a live post to this container.
public
addComponent(Component $component) : self
Posts are rendered in the order they are added. Apple expects reverse chronological order, so add the newest post first.
Parameters
- $component : Component
-
The LivePost to add.
Tags
Return values
selfgetComponents()
Get the child components, in the order they were added.
public
getComponents() : array<int, Component>
Return values
array<int, Component>getRole()
Get the role name for the component (e.g., 'body', 'photo', 'heading1').
public
getRole() : string
Return values
stringgetStyle()
Get the component style name.
public
getStyle() : string|null
Return values
string|null —The name set with setStyle(), or null.
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
staticsetAnimation()
Set component animation using an array.
public
setAnimation(array<string, mixed> $animation) : static
Parameters
- $animation : array<string, mixed>
-
Animation properties.
Tags
Return values
staticsetAnimationObject()
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
staticsetBehavior()
Set the component behavior using an array.
public
setBehavior(array<string, mixed> $behavior) : static
Parameters
- $behavior : array<string, mixed>
-
The behavior configuration array.
Tags
Return values
staticsetBehaviorObject()
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
staticsetConditional()
Set conditional properties for the component.
public
setConditional(array<string, mixed> $conditional) : static
Parameters
- $conditional : array<string, mixed>
-
Array of conditions.
Tags
Return values
staticsetContentDisplay()
Set the content display mode using a string or array.
public
setContentDisplay(string|array<string, mixed> $contentDisplay) : $this
Parameters
- $contentDisplay : string|array<string, mixed>
-
The display mode or configuration.
Return values
$thissetContentDisplayObject()
Set the content display mode using a typed ContentDisplay object.
public
setContentDisplayObject(ContentDisplayInterface $contentDisplay) : $this
This method provides type-safe content display configuration:
$container->setContentDisplayObject(new HorizontalStackDisplay());
$container->setContentDisplayObject(CollectionDisplay::grid(20, 20));
Parameters
- $contentDisplay : ContentDisplayInterface
-
The content display object.
Return values
$thissetHidden()
Set whether the component is hidden.
public
setHidden(bool $hidden) : static
Parameters
- $hidden : bool
-
Whether to hide the component.
Return values
staticsetIdentifier()
Set the identifier for this container.
public
setIdentifier(string $identifier) : static
Apple requires an identifier on every live_container, so an empty string is rejected.
Parameters
- $identifier : string
-
Identifier, unique across the article.
Tags
Return values
staticsetLayout()
Set the layout name or inline layout.
public
setLayout(string $layout) : static
Parameters
- $layout : string
-
Reference to a name in componentLayouts.
Return values
staticsetStyle()
Set the style name.
public
setStyle(string $style) : static
Parameters
- $style : string
-
Reference to a name in componentStyles.
Return values
staticgetBaseProperties()
Get the base properties common to all components for JSON serialization.
protected
getBaseProperties() : array<string, mixed>