PHP 클래스 FluentDOM\Nodes

상속: implements ArrayAccess, implements Countable, implements IteratorAggregate
파일 보기 프로젝트 열기: fluentdom/fluentdom 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$_nodes DOMNode[]
$_parent Nodes | null
$_useDocumentContext boolean Use document context for expression (not selected nodes).

공개 메소드들

메소드 설명
__construct ( mixed $source = NULL, null | string $contentType = 'text/xml' )
__get ( string $name ) : mixed Virtual properties, read property
__isset ( string $name ) : boolean Virtual properties, validate existence
__set ( string $name, mixed $value ) Block changing the readonly dynamic property
__toString ( ) : string Return the output of the internal dom document
__unset ( string $name ) Throws an exception if somebody tries to unset one of the dynamic properties
count ( ) : integer Countable interface
each ( callable $function, callable | boolean | null $elementsFilter = NULL ) Execute a function within the context of every matched element.
end ( ) : Nodes Return the parent FluentDOM\Nodes object.
find ( mixed $selector, integer $options ) : Nodes Searches for descendant elements that match the specified expression.
formatOutput ( string $contentType = NULL ) : Nodes Formats the current document, resets internal node array and other properties.
getDocument ( ) : DOMDocument | Document Get the associated DOM, create one if here isn't one yet.
getIterator ( ) : NodesIterator IteratorAggregate interface
getLoadingOptions ( null | string $contentType = NULL ) : array | mixed Return the options from the original loading action, but only if the content type equals the loaded content type.
getSelectorCallback ( null | callable | string | array | DOMNode | Traversable $selector ) : callable | null Returns a callback that can be used to validate if an node matches the selector.
index ( null | string | DOMNode | Traversable $selector = NULL ) : integer Search for a given element from among the matched elements.
item ( integer $position ) : DOMElement | DOMNode The item() method is used to access elements in the node list, like in a DOMNodeList.
load ( mixed $source, string $contentType = 'text/xml', array | Traversable | Options $options = [] ) Load a $source. The type of the source depends on the loaders. If no explicit loaders are set it will use a set of default loaders for xml/html and json.
loaders ( fluentdom\Loadable | array | Traversable $loaders = NULL ) : fluentdom\Loadable Set the loaders list.
offsetExists ( integer $offset ) : boolean Check if index exists in internal array
offsetGet ( integer $offset ) : DOMElement | DOMNode | null Get element from internal array
offsetSet ( integer $offset, mixed $value ) If somebody tries to modify the internal array throw an exception.
offsetUnset ( integer $offset ) If somebody tries to remove an element from the internal array throw an exception.
prepareSelector ( string $selector, integer $contextMode ) : string Use callback to convert selector if it is set.
push ( DOMNode | Traversable | array | null $elements, boolean $ignoreTextNodes = FALSE ) Push new element(s) an the internal element list
registerNamespace ( string $prefix, string $namespace ) Register a namespace for selectors/expressions
serializerFactories ( Group $factories = NULL ) : Group
spawn ( array | Traversable | DOMNode | Nodes $elements = NULL ) : Nodes Create a new instance of the same class with $this as the parent. This is used for the chaining.
toArray ( ) : DOMNode[] Retrieve the matched DOM nodes in an array.
toString ( ) : string Return the output of the internal dom document
unique ( array $array ) : array Sorts an array of DOM nodes based on document position, in place, with the duplicates removed.
xpath ( string $expression = NULL, DOMNode $contextNode = NULL ) : Xpath | DOMNodeList | float | string

보호된 메소드들

메소드 설명
fetch ( string $expression, null | string | callable | DOMNode | array | Traversable $filter = NULL, null | string | callable | DOMNode | array | Traversable $stopAt = NULL, integer $options ) : Nodes Fetch spawns and fills a Nodes instance.
matches ( string $selector, DOMNode $context = NULL ) : boolean Test that selector matches context and return true/false

비공개 메소드들

메소드 설명
applyNamespaces ( ) apply stored namespaces to attached document or xpath object
getXpath ( ) : Xpath
prepareFindContext ( mixed $selector, integer $options ) : array
prepareSelectorAsFilter ( $selector, $contextMode )
prepareSource ( mixed $source, string $contentType, array | Traversable | Options $options ) : boolean | DOMDocument | Document | null
setContentType ( string $value ) Setter for Nodes::_contentType property

메소드 상세

__construct() 공개 메소드

public __construct ( mixed $source = NULL, null | string $contentType = 'text/xml' )
$source mixed
$contentType null | string

__get() 공개 메소드

Virtual properties, read property
public __get ( string $name ) : mixed
$name string
리턴 mixed

__isset() 공개 메소드

Virtual properties, validate existence
public __isset ( string $name ) : boolean
$name string
리턴 boolean

__set() 공개 메소드

Block changing the readonly dynamic property
public __set ( string $name, mixed $value )
$name string
$value mixed

__toString() 공개 메소드

Return the output of the internal dom document
public __toString ( ) : string
리턴 string

__unset() 공개 메소드

Throws an exception if somebody tries to unset one of the dynamic properties
public __unset ( string $name )
$name string

count() 공개 메소드

Countable interface
public count ( ) : integer
리턴 integer

each() 공개 메소드

If $elementsOnly is a callable the return value defines if it is called for that node. If $elementsOnly is set to TRUE, only element nodes are used.
public each ( callable $function, callable | boolean | null $elementsFilter = NULL )
$function callable
$elementsFilter callable | boolean | null

end() 공개 메소드

Return the parent FluentDOM\Nodes object.
public end ( ) : Nodes
리턴 Nodes

fetch() 보호된 메소드

Fetch spawns and fills a Nodes instance.
protected fetch ( string $expression, null | string | callable | DOMNode | array | Traversable $filter = NULL, null | string | callable | DOMNode | array | Traversable $stopAt = NULL, integer $options ) : Nodes
$expression string Xpath expression
$filter null | string | callable | DOMNode | array | Traversable
$stopAt null | string | callable | DOMNode | array | Traversable
$options integer
리턴 Nodes

find() 공개 메소드

If the $selector is an node or a list of nodes all descendants that match that node/node list are returned. self::CONTEXT_DOCUMENT will use the document element as context. Otherwise the currently nodes are used as contexts self::FIND_MODE_FILTER will use the $selector only as filter and not execute it directly. this is the like the jQuery specification - but a lot slower and needs more memory. Additionally in this mode, it will find only element nodes. *
public find ( mixed $selector, integer $options ) : Nodes
$selector mixed selector
$options integer FIND_* options CONTEXT_DOCUMENT, FIND_MODE_FILTER, FIND_FORCE_SORT
리턴 Nodes

formatOutput() 공개 메소드

The document is saved and reloaded, all variables with DOMNodes of this document will get invalid.
public formatOutput ( string $contentType = NULL ) : Nodes
$contentType string
리턴 Nodes

getDocument() 공개 메소드

Get the associated DOM, create one if here isn't one yet.
public getDocument ( ) : DOMDocument | Document
리턴 DOMDocument | Document

getIterator() 공개 메소드

IteratorAggregate interface
public getIterator ( ) : NodesIterator
리턴 FluentDOM\Iterators\NodesIterator

getLoadingOptions() 공개 메소드

Return the options from the original loading action, but only if the content type equals the loaded content type.
public getLoadingOptions ( null | string $contentType = NULL ) : array | mixed
$contentType null | string
리턴 array | mixed

getSelectorCallback() 공개 메소드

Returns a callback that can be used to validate if an node matches the selector.
public getSelectorCallback ( null | callable | string | array | DOMNode | Traversable $selector ) : callable | null
$selector null | callable | string | array | DOMNode | Traversable
리턴 callable | null

index() 공개 메소드

Search for a given element from among the matched elements.
public index ( null | string | DOMNode | Traversable $selector = NULL ) : integer
$selector null | string | DOMNode | Traversable
리턴 integer

item() 공개 메소드

The item() method is used to access elements in the node list, like in a DOMNodeList.
public item ( integer $position ) : DOMElement | DOMNode
$position integer
리턴 DOMElement | DOMNode

load() 공개 메소드

Load a $source. The type of the source depends on the loaders. If no explicit loaders are set it will use a set of default loaders for xml/html and json.
public load ( mixed $source, string $contentType = 'text/xml', array | Traversable | Options $options = [] )
$source mixed
$contentType string optional, default value 'text/xml'
$options array | Traversable | FluentDOM\Loader\Options

loaders() 공개 메소드

Set the loaders list.
public loaders ( fluentdom\Loadable | array | Traversable $loaders = NULL ) : fluentdom\Loadable
$loaders fluentdom\Loadable | array | Traversable
리턴 fluentdom\Loadable

matches() 보호된 메소드

Test that selector matches context and return true/false
protected matches ( string $selector, DOMNode $context = NULL ) : boolean
$selector string
$context DOMNode optional, default value NULL
리턴 boolean

offsetExists() 공개 메소드

Check if index exists in internal array
public offsetExists ( integer $offset ) : boolean
$offset integer
리턴 boolean

offsetGet() 공개 메소드

Get element from internal array
public offsetGet ( integer $offset ) : DOMElement | DOMNode | null
$offset integer
리턴 DOMElement | DOMNode | null

offsetSet() 공개 메소드

If somebody tries to modify the internal array throw an exception.
public offsetSet ( integer $offset, mixed $value )
$offset integer
$value mixed

offsetUnset() 공개 메소드

If somebody tries to remove an element from the internal array throw an exception.
public offsetUnset ( integer $offset )
$offset integer

prepareSelector() 공개 메소드

Use callback to convert selector if it is set.
public prepareSelector ( string $selector, integer $contextMode ) : string
$selector string
$contextMode integer
리턴 string

push() 공개 메소드

Push new element(s) an the internal element list
public push ( DOMNode | Traversable | array | null $elements, boolean $ignoreTextNodes = FALSE )
$elements DOMNode | Traversable | array | null
$ignoreTextNodes boolean ignore text nodes

registerNamespace() 공개 메소드

Register a namespace for selectors/expressions
public registerNamespace ( string $prefix, string $namespace )
$prefix string
$namespace string

serializerFactories() 공개 메소드

public serializerFactories ( Group $factories = NULL ) : Group
$factories FluentDOM\Serializer\Factory\Group
리턴 FluentDOM\Serializer\Factory\Group

spawn() 공개 메소드

Create a new instance of the same class with $this as the parent. This is used for the chaining.
public spawn ( array | Traversable | DOMNode | Nodes $elements = NULL ) : Nodes
$elements array | Traversable | DOMNode | Nodes
리턴 Nodes

toArray() 공개 메소드

Retrieve the matched DOM nodes in an array.
public toArray ( ) : DOMNode[]
리턴 DOMNode[]

toString() 공개 메소드

Return the output of the internal dom document
public toString ( ) : string
리턴 string

unique() 공개 메소드

Note that this only works on arrays of DOM nodes, not strings or numbers.
public unique ( array $array ) : array
$array array array of DOM nodes
리턴 array

xpath() 공개 메소드

public xpath ( string $expression = NULL, DOMNode $contextNode = NULL ) : Xpath | DOMNodeList | float | string
$expression string
$contextNode DOMNode
리턴 Xpath | DOMNodeList | float | string

프로퍼티 상세

$_nodes 보호되어 있는 프로퍼티

protected DOMNode[] $_nodes
리턴 DOMNode[]

$_parent 보호되어 있는 프로퍼티

protected Nodes,fluentdom|NULL $_parent
리턴 Nodes | null

$_useDocumentContext 보호되어 있는 프로퍼티

Use document context for expression (not selected nodes).
protected bool $_useDocumentContext
리턴 boolean