PHP 클래스 Apple_Exporter\Components\Component

It provides several helper methods, such as get/set_setting and register_style.
부터: 0.2.0
파일 보기 프로젝트 열기: alleyinteractive/apple-news 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$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.

보호된 프로퍼티들

프로퍼티 타입 설명
$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