PHP 클래스 Webiny\Component\Entity\EntityCollection

상속: implements IteratorAggregate, implements ArrayAccess, implements Countable, use trait Webiny\Component\Mongo\MongoTrait, use trait Webiny\Component\StdLib\StdLibTrait
파일 보기 프로젝트 열기: Webiny/Framework

공개 메소드들

메소드 설명
__construct ( string $entityClass, array $data = [], array $parameters = [] )
__toString ( ) : mixed | null | string Get string of masked entity values when array of instances is being converted to string
contains ( string | AbstractEntity $item ) : boolean Check if given item is already in the data set.
NOTE: this triggers loading of data from database if not yet loaded
count ( ) : mixed Count items in entity collection
delete ( ) : boolean Delete all items in the result set (WARNING: removes data from database)
first ( ) : AbstractEntity | null Gets first entity in collection
getData ( ) : array Get collection data
getIterator ( )
getLimit ( )
getOffset ( )
last ( ) : AbstractEntity | null Gets last entity in collection
offsetExists ( $offset )
offsetGet ( $offset )
offsetSet ( $offset, $value )
offsetUnset ( $offset )
randomize ( ) Shuffle values (useful when you want to fetch a random value)
removeItem ( $item ) Remove item from data set
toArray ( string $fields = '' ) : array Convert EntityCollection to array.
totalCount ( ) : mixed Count total number of items in collection

보호된 메소드들

메소드 설명
normalizeValue ( array | AbstractEntity $item, boolean $fromDb = false ) : AbstractEntity Normalize value to always be an instance of AbstractEntity

메소드 상세

__construct() 공개 메소드

public __construct ( string $entityClass, array $data = [], array $parameters = [] )
$entityClass string Entity class
$data array Array of data to be converted to EntityCollection
$parameters array Parameters used to load given data

__toString() 공개 메소드

Get string of masked entity values when array of instances is being converted to string
public __toString ( ) : mixed | null | string
리턴 mixed | null | string

contains() 공개 메소드

TODO: unittest
public contains ( string | AbstractEntity $item ) : boolean
$item string | AbstractEntity ID or AbstractEntity instance
리턴 boolean

count() 공개 메소드

Count items in entity collection
public count ( ) : mixed
리턴 mixed

delete() 공개 메소드

Delete all items in the result set (WARNING: removes data from database)
public delete ( ) : boolean
리턴 boolean

first() 공개 메소드

Gets first entity in collection
public first ( ) : AbstractEntity | null
리턴 AbstractEntity | null

getData() 공개 메소드

Get collection data
public getData ( ) : array
리턴 array

getIterator() 공개 메소드

public getIterator ( )

getLimit() 공개 메소드

public getLimit ( )

getOffset() 공개 메소드

public getOffset ( )

last() 공개 메소드

Gets last entity in collection
public last ( ) : AbstractEntity | null
리턴 AbstractEntity | null

normalizeValue() 보호된 메소드

Normalize value to always be an instance of AbstractEntity
protected normalizeValue ( array | AbstractEntity $item, boolean $fromDb = false ) : AbstractEntity
$item array | AbstractEntity
$fromDb boolean Is $item coming from DB
리턴 AbstractEntity

offsetExists() 공개 메소드

public offsetExists ( $offset )

offsetGet() 공개 메소드

public offsetGet ( $offset )

offsetSet() 공개 메소드

public offsetSet ( $offset, $value )

offsetUnset() 공개 메소드

public offsetUnset ( $offset )

randomize() 공개 메소드

Shuffle values (useful when you want to fetch a random value)
public randomize ( )

removeItem() 공개 메소드

Remove item from data set
public removeItem ( $item )
$item

toArray() 공개 메소드

Each AbstractEntity wil be converted to array using $fields which can be defined as a comma-separated keys, or as a function which will be ran with each entity - this gives the possibility to return different data sets depending on the given function
public toArray ( string $fields = '' ) : array
$fields string List of fields to extract
리턴 array

totalCount() 공개 메소드

TODO: unittest
public totalCount ( ) : mixed
리턴 mixed