PHP 클래스 Puli\Repository\Resource\Iterator\ResourceCollectionIterator

Use the iterator if you want to iterate a resource collection. You can configure what the iterator should return as keys and values: php $iterator = new ResourceCollectionIterator( $collection, ResourceCollectionIterator::KEY_AS_PATH | ResourceCollectionIterator::CURRENT_AS_RESOURCE ); foreach ($iterator as $path => $resource) { ... } If you want to iterate the collection recursively, wrap it in a {@link RecursiveResourceIteratorIterator}: php $iterator = new RecursiveResourceIteratorIterator( new ResourceCollectionIterator( $collection, ResourceCollectionIterator::KEY_AS_PATH | ResourceCollectionIterator::CURRENT_AS_RESOURCE ), RecursiveResourceIteratorIterator::SELF_FIRST ); foreach ($iterator as $path => $resource) { ... }
부터: 1.0
저자: Bernhard Schussek ([email protected])
상속: implements RecursiveResourceIterator
파일 보기 프로젝트 열기: puli/repository 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$mode integer
$resources Puli\Repository\Api\Resource\PuliResource[]

공개 메소드들

메소드 설명
__construct ( Puli\Repository\Api\ResourceCollection $resources, integer | null $mode = null ) Creates a new iterator.
current ( ) : Puli\Repository\Api\Resource\PuliResource | string Returns the current value of the iterator.
getChildren ( ) : static Returns the iterator for the children of the current element.
getCurrentResource ( )
hasChildren ( ) : boolean Returns whether the iterator can be applied recursively over the current element.
key ( ) : integer | string | null Returns the current key of the iterator.
next ( ) Advances the iterator to the next position.
rewind ( ) Rewinds the iterator to the first entry.
valid ( ) : boolean Returns whether the iterator points to a valid key.

메소드 상세

__construct() 공개 메소드

The following constants can be used to configure the values returned by the iterator: * {@link CURRENT_AS_RESOURCE}: The {@link PuliResource} objects are returned as values; * {@link CURRENT_AS_PATH}: The resource paths are returned as values; * {@link CURRENT_AS_NAME}: The resource names are returned as values. The following constants can be used to configure the keys returned by the iterator: * {@link KEY_AS_CURSOR}: The collection keys are returned as keys; * {@link KEY_AS_PATH}: The resource paths are returned as keys. By default, the mode KEY_AS_PATH | CURRENT_AS_RESOURCE is used.
public __construct ( Puli\Repository\Api\ResourceCollection $resources, integer | null $mode = null )
$resources Puli\Repository\Api\ResourceCollection The resources to iterate.
$mode integer | null A bitwise combination of the mode constants.

current() 공개 메소드

Returns the current value of the iterator.
public current ( ) : Puli\Repository\Api\Resource\PuliResource | string
리턴 Puli\Repository\Api\Resource\PuliResource | string The current value as configured in {@link __construct}.

getChildren() 공개 메소드

Returns the iterator for the children of the current element.
public getChildren ( ) : static
리턴 static Returns an instance of this class for the children of the current element.

getCurrentResource() 공개 메소드

public getCurrentResource ( )

hasChildren() 공개 메소드

Returns whether the iterator can be applied recursively over the current element.
public hasChildren ( ) : boolean
리턴 boolean Whether the current element can be iterated recursively.

key() 공개 메소드

Returns the current key of the iterator.
public key ( ) : integer | string | null
리턴 integer | string | null The current key as configured in {@link __construct} or `null` if the cursor is behind the last element.

next() 공개 메소드

Advances the iterator to the next position.
public next ( )

rewind() 공개 메소드

Rewinds the iterator to the first entry.
public rewind ( )

valid() 공개 메소드

Returns whether the iterator points to a valid key.
public valid ( ) : boolean
리턴 boolean Whether the iterator position is valid.

프로퍼티 상세

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

protected int $mode
리턴 integer

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

protected PuliResource[],Puli\Repository\Api\Resource $resources
리턴 Puli\Repository\Api\Resource\PuliResource[]