PHP Class Apple_Exporter\Components\Component

It provides several helper methods, such as get/set_setting and register_style.
Since: 0.2.0
Afficher le fichier Open project: alleyinteractive/apple-news Class Usage Examples

Méthodes publiques

Свойство Type Description
$anchor_position integer Anchorable components are anchored to the previous element that appears in the position specified. If the previous element is an advertisement, attaches to the next instead of the previous element.
$needs_layout_if_anchored boolean Right now, the only component that sets this to false is the body, as it doesn't need a special layout for anchoring, it just flows around anchored components.

Protected Properties

Свойство Type Description
$can_be_anchor_target boolean Whether this component can be an anchor target.
$json array JSON for this component.
$layouts Component_Layouts Layouts for this component.
$settings Settings Settings for this component.
$styles Component_Text_Styles Styles for this component.
$text string Text for this component.
$workspace Workspace Workspace for this component.

Méthodes publiques

Méthode Description
__construct ( string $text, Workspace $workspace, Settings $settings, Component_Text_Styles $styles, Component_Layouts $layouts, Markdown $markdown = null ) Constructor.
anchor ( ) Sets the anchor layout for this component
can_be_anchor_target ( ) : boolean Check if it's can_be_anchor_target and it hasn't been anchored already.
get_anchor_position ( ) : integer Get the anchor position.
get_component_name ( ) : string Gets the name of this component from the class name.
get_json ( string $name ) : mixed Get a JSON value
is_anchor_target ( ) : boolean All components that are anchor target have an UID. Return whether this component is an anchor target.
node_matches ( DomNode $node ) : mixed Given a DomNode, if it matches the component, return the relevant node to work on. Otherwise, return null.
set_anchor_position ( integer $position ) Set the anchor position.
set_json ( string $name, mixed $value ) Set a JSON value.
to_array ( ) : array Transforms HTML into an array that describes the component using the build function.
uid ( ) : string Get the current UID.

Méthodes protégées

Méthode Description
build ( string $text ) This function is in charge of transforming HTML into a Article Format valid array.
bundle_source ( string $filename, string $source ) Calls the current workspace bundle_source method to allow for different implementations of the bundling technique.
clean_html ( string $html ) : string Use PHP's HTML parser to generate valid HTML out of potentially broken input.
find_text_alignment ( ) : string Some components follow this rule: 1. If the body is centered, text here should be centered too 2. Otherwise, align left
get_setting ( string $name ) : mixed Gets an exporter setting.
maybe_bundle_source ( string $source, string $filename = null ) : string Maybe bundles the source based on current settings.
node_has_class ( DomNode $node, string $classname ) : boolean Check if a node has a class.
register_full_width_layout ( string $name, array $spec ) Register a new layout which will be displayed as full-width, so no need to specify columnStart and columnSpan in the layout specs. This is useful because when the body is centered, the full-width layout spans the same columns as the body.
register_layout ( string $name, array $spec ) Using the layouts service, register a new layout.
register_style ( string $name, array $spec ) Using the style service, register a new style.
remote_file_exists ( DomNode $node ) : boolean Check if the remote file exists for this node.
set_setting ( string $name, mixed $value ) : boolean Sets an exporter setting.

Method Details

__construct() public méthode

Constructor.
public __construct ( string $text, Workspace $workspace, Settings $settings, Component_Text_Styles $styles, Component_Layouts $layouts, Markdown $markdown = null )
$text string
$workspace Workspace
$settings Settings
$styles Component_Text_Styles
$layouts Component_Layouts
$markdown Markdown

anchor() public méthode

Sets the anchor layout for this component
Since: 0.6.0
public anchor ( )

build() abstract protected méthode

This function is in charge of transforming HTML into a Article Format valid array.
abstract protected build ( string $text )
$text string

bundle_source() protected méthode

Calls the current workspace bundle_source method to allow for different implementations of the bundling technique.
protected bundle_source ( string $filename, string $source )
$filename string The name of the file to be created
$source string The path or URL of the resource which is going to be bundled

can_be_anchor_target() public méthode

Check if it's can_be_anchor_target and it hasn't been anchored already.
public can_be_anchor_target ( ) : boolean
Résultat boolean

clean_html() protected static méthode

Use PHP's HTML parser to generate valid HTML out of potentially broken input.
protected static clean_html ( string $html ) : string
$html string
Résultat string

find_text_alignment() protected méthode

This method returns either 'center' or 'left', as needed.
Since: 0.8.0
protected find_text_alignment ( ) : string
Résultat string

get_anchor_position() public méthode

Get the anchor position.
public get_anchor_position ( ) : integer
Résultat integer

get_component_name() public méthode

Gets the name of this component from the class name.
public get_component_name ( ) : string
Résultat string

get_json() public méthode

Get a JSON value
public get_json ( string $name ) : mixed
$name string
Résultat mixed

get_setting() protected méthode

Gets an exporter setting.
Since: 0.4.0
protected get_setting ( string $name ) : mixed
$name string
Résultat mixed

is_anchor_target() public méthode

All components that are anchor target have an UID. Return whether this component is an anchor target.
Since: 0.6.0
public is_anchor_target ( ) : boolean
Résultat boolean

maybe_bundle_source() protected méthode

Returns the URL to use based on current setings.
protected maybe_bundle_source ( string $source, string $filename = null ) : string
$source string The path or URL of the resource which is going to be bundled
$filename string The name of the file to be created
Résultat string The URL to use for this asset in the JSON

node_has_class() protected static méthode

Check if a node has a class.
protected static node_has_class ( DomNode $node, string $classname ) : boolean
$node DomNode
$classname string
Résultat boolean

node_matches() public static méthode

Given a DomNode, if it matches the component, return the relevant node to work on. Otherwise, return null.
public static node_matches ( DomNode $node ) : mixed
$node DomNode
Résultat mixed

register_full_width_layout() protected méthode

Register a new layout which will be displayed as full-width, so no need to specify columnStart and columnSpan in the layout specs. This is useful because when the body is centered, the full-width layout spans the same columns as the body.
protected register_full_width_layout ( string $name, array $spec )
$name string
$spec array

register_layout() protected méthode

Using the layouts service, register a new layout.
Since: 0.4.0
protected register_layout ( string $name, array $spec )
$name string
$spec array

register_style() protected méthode

Using the style service, register a new style.
Since: 0.4.0
protected register_style ( string $name, array $spec )
$name string
$spec array

remote_file_exists() protected static méthode

Check if the remote file exists for this node.
protected static remote_file_exists ( DomNode $node ) : boolean
$node DomNode
Résultat boolean

set_anchor_position() public méthode

Set the anchor position.
public set_anchor_position ( integer $position )
$position integer

set_json() public méthode

Set a JSON value.
public set_json ( string $name, mixed $value )
$name string
$value mixed

set_setting() protected méthode

Sets an exporter setting.
Since: 0.4.0
protected set_setting ( string $name, mixed $value ) : boolean
$name string
$value mixed
Résultat boolean

to_array() public méthode

Transforms HTML into an array that describes the component using the build function.
public to_array ( ) : array
Résultat array

uid() public méthode

Get the current UID.
public uid ( ) : string
Résultat string

Property Details

$anchor_position public_oe property

Anchorable components are anchored to the previous element that appears in the position specified. If the previous element is an advertisement, attaches to the next instead of the previous element.
Since: 0.6.0
public int $anchor_position
Résultat integer

$can_be_anchor_target protected_oe property

Whether this component can be an anchor target.
Since: 0.6.0
protected bool $can_be_anchor_target
Résultat boolean

$json protected_oe property

JSON for this component.
Since: 0.2.0
protected array $json
Résultat array

$layouts protected_oe property

Layouts for this component.
Since: 0.4.0
protected Component_Layouts $layouts
Résultat Component_Layouts

$needs_layout_if_anchored public_oe property

Right now, the only component that sets this to false is the body, as it doesn't need a special layout for anchoring, it just flows around anchored components.
Since: 0.6.0
public bool $needs_layout_if_anchored
Résultat boolean

$settings protected_oe property

Settings for this component.
Since: 0.4.0
protected Settings $settings
Résultat Settings

$styles protected_oe property

Styles for this component.
Since: 0.4.0
protected Component_Text_Styles $styles
Résultat Component_Text_Styles

$text protected_oe property

Text for this component.
Since: 0.2.0
protected string $text
Résultat string

$workspace protected_oe property

Workspace for this component.
Since: 0.2.0
protected Workspace $workspace
Résultat Workspace