PHP Класс Apple_Exporter\Components\Component

It provides several helper methods, such as get/set_setting and register_style.
С версии: 0.2.0
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$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)

Свойство Тип Описание
$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.

Открытые методы

Метод Описание
__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.

Защищенные методы

Метод Описание
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.

Описание методов

__construct() публичный метод

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() публичный метод

Sets the anchor layout for this component
С версии: 0.6.0
public anchor ( )

build() абстрактный защищенный метод

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

bundle_source() защищенный метод

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() публичный метод

Check if it's can_be_anchor_target and it hasn't been anchored already.
public can_be_anchor_target ( ) : boolean
Результат boolean

clean_html() защищенный статический метод

Use PHP's HTML parser to generate valid HTML out of potentially broken input.
protected static clean_html ( string $html ) : string
$html string
Результат string

find_text_alignment() защищенный метод

This method returns either 'center' or 'left', as needed.
С версии: 0.8.0
protected find_text_alignment ( ) : string
Результат string

get_anchor_position() публичный метод

Get the anchor position.
public get_anchor_position ( ) : integer
Результат integer

get_component_name() публичный метод

Gets the name of this component from the class name.
public get_component_name ( ) : string
Результат string

get_json() публичный метод

Get a JSON value
public get_json ( string $name ) : mixed
$name string
Результат mixed

get_setting() защищенный метод

Gets an exporter setting.
С версии: 0.4.0
protected get_setting ( string $name ) : mixed
$name string
Результат mixed

is_anchor_target() публичный метод

All components that are anchor target have an UID. Return whether this component is an anchor target.
С версии: 0.6.0
public is_anchor_target ( ) : boolean
Результат boolean

maybe_bundle_source() защищенный метод

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
Результат string The URL to use for this asset in the JSON

node_has_class() защищенный статический метод

Check if a node has a class.
protected static node_has_class ( DomNode $node, string $classname ) : boolean
$node DomNode
$classname string
Результат boolean

node_matches() публичный статический метод

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
Результат mixed

register_full_width_layout() защищенный метод

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() защищенный метод

Using the layouts service, register a new layout.
С версии: 0.4.0
protected register_layout ( string $name, array $spec )
$name string
$spec array

register_style() защищенный метод

Using the style service, register a new style.
С версии: 0.4.0
protected register_style ( string $name, array $spec )
$name string
$spec array

remote_file_exists() защищенный статический метод

Check if the remote file exists for this node.
protected static remote_file_exists ( DomNode $node ) : boolean
$node DomNode
Результат boolean

set_anchor_position() публичный метод

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

set_json() публичный метод

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

set_setting() защищенный метод

Sets an exporter setting.
С версии: 0.4.0
protected set_setting ( string $name, mixed $value ) : boolean
$name string
$value mixed
Результат boolean

to_array() публичный метод

Transforms HTML into an array that describes the component using the build function.
public to_array ( ) : array
Результат array

uid() публичный метод

Get the current UID.
public uid ( ) : string
Результат string

Описание свойств

$anchor_position публичное свойство

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.
С версии: 0.6.0
public int $anchor_position
Результат integer

$can_be_anchor_target защищенное свойство

Whether this component can be an anchor target.
С версии: 0.6.0
protected bool $can_be_anchor_target
Результат boolean

$json защищенное свойство

JSON for this component.
С версии: 0.2.0
protected array $json
Результат array

$layouts защищенное свойство

Layouts for this component.
С версии: 0.4.0
protected Component_Layouts $layouts
Результат Component_Layouts

$needs_layout_if_anchored публичное свойство

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.
С версии: 0.6.0
public bool $needs_layout_if_anchored
Результат boolean

$settings защищенное свойство

Settings for this component.
С версии: 0.4.0
protected Settings $settings
Результат Settings

$styles защищенное свойство

Styles for this component.
С версии: 0.4.0
protected Component_Text_Styles $styles
Результат Component_Text_Styles

$text защищенное свойство

Text for this component.
С версии: 0.2.0
protected string $text
Результат string

$workspace защищенное свойство

Workspace for this component.
С версии: 0.2.0
protected Workspace $workspace
Результат Workspace