PHP 클래스 Sokil\Mongo\Structure

상속: implements Sokil\Mongo\ArrayableInterface, implements JsonSerializable
파일 보기 프로젝트 열기: sokil/php-mongo 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$_data array
$schema array Initial document's data

공개 메소드들

메소드 설명
__clone ( ) Cloning not allowed because cloning of object not clone related aggregates of this object, so cloned object has links to original aggregates. This is difficult to handle.
__construct ( array $data = null, boolean | true $notModified = true )
__get ( $name )
__isset ( $name )
__set ( string $name, mixed $value ) Handle setting params through public property
addError ( string $fieldName, string $ruleName, string $message ) : Document Add validator error from validator classes and methods. This error reset on every re-validation
addErrors ( array $errors ) : Document Add errors
addValidatorNamespace ( type $namespace ) : Document Add own namespace of validators
append ( type $selector, type $value ) : Structure If field not exist - set value.
apply ( ) Apply modified document fields as original
clearErrors ( ) Clear triggered and validation errors
clearTriggeredErrors ( ) : Document Remove custom errors
get ( $selector )
getErrors ( ) : array get list of validation errors
getModifiedFields ( )
getObject ( string $selector, string | callable $className = '\Sokil\Mongo\Structure' ) : object Get structure object from a document's value
getObjectList ( string $selector, string | callable $className = '\Sokil\Mongo\Structure' ) : object Get list of structure objects from list of values in mongo document
getOriginalData ( )
getScenario ( )
has ( $selector )
hasErrors ( )
isModified ( $selector = null )
isScenario ( $scenario )
isValid ( ) : boolean check if filled model params is valid
jsonSerialize ( )
merge ( array $data ) : Structure Merge array to current structure with setting modification mark
mergeUnmodified ( array $data ) : Structure Merge array to current structure without setting modification mark
prepareToStore ( $value )
replace ( array $data ) Replace data of document with passed.
reset ( ) Replace modified fields with original
rules ( ) : array Validation rules
set ( string $selector, mixed $value ) : Document Store value to specified selector in local cache
setNoScenario ( )
setScenario ( $scenario )
toArray ( )
triggerError ( type $fieldName, type $ruleName, type $message ) : Document Add custom error which not reset after validation
triggerErrors ( array $errors ) : Document Add custom errors
unsetField ( $selector )

보호된 메소드들

메소드 설명
setDataReference ( array &$data ) : Structure IMPORTANT! Do not use this method

비공개 메소드들

메소드 설명
getValidatorClassNameByRuleName ( $ruleName )
isEmbeddedDocument ( array $array ) Check if array is sequential list
mergePartial ( array &$document, array $updatedDocument, string $prefix = null ) Recursive function to merge data for Structure::merge()
mergeUnmodifiedPartial ( array &$target, array $source ) Recursive function to merge data for Structure::mergeUnmodified()

메소드 상세

__clone() 최종 공개 메소드

Cloning not allowed because cloning of object not clone related aggregates of this object, so cloned object has links to original aggregates. This is difficult to handle.
final public __clone ( )

__construct() 공개 메소드

public __construct ( array $data = null, boolean | true $notModified = true )
$data array data to initialise structure
$notModified boolean | true define if data set as modified or not

__get() 공개 메소드

public __get ( $name )

__isset() 공개 메소드

public __isset ( $name )

__set() 공개 메소드

Handle setting params through public property
public __set ( string $name, mixed $value )
$name string
$value mixed

addError() 공개 메소드

Add validator error from validator classes and methods. This error reset on every re-validation
public addError ( string $fieldName, string $ruleName, string $message ) : Document
$fieldName string dot-notated field name
$ruleName string name of validation rule
$message string error message
리턴 Document

addErrors() 공개 메소드

Add errors
public addErrors ( array $errors ) : Document
$errors array
리턴 Document

addValidatorNamespace() 공개 메소드

Add own namespace of validators
public addValidatorNamespace ( type $namespace ) : Document
$namespace type
리턴 Document

append() 공개 메소드

If field exists and is not array - convert to array and append If field -s array - append
public append ( type $selector, type $value ) : Structure
$selector type
$value type
리턴 Structure

apply() 공개 메소드

Apply modified document fields as original
public apply ( )

clearErrors() 공개 메소드

Clear triggered and validation errors
public clearErrors ( )

clearTriggeredErrors() 공개 메소드

Remove custom errors
public clearTriggeredErrors ( ) : Document
리턴 Document

get() 공개 메소드

public get ( $selector )

getErrors() 공개 메소드

Format: $errors['fieldName']['rule'] = 'message';
public getErrors ( ) : array
리턴 array list of validation errors

getModifiedFields() 공개 메소드

public getModifiedFields ( )

getObject() 공개 메소드

Get structure object from a document's value
public getObject ( string $selector, string | callable $className = '\Sokil\Mongo\Structure' ) : object
$selector string
$className string | callable string class name or closure, which accept data and return string class name
리턴 object representation of document with class, passed as argument

getObjectList() 공개 메소드

Get list of structure objects from list of values in mongo document
public getObjectList ( string $selector, string | callable $className = '\Sokil\Mongo\Structure' ) : object
$selector string
$className string | callable Structure class name or closure, which accept data and return string class name of Structure
리턴 object representation of document with class, passed as argument

getOriginalData() 공개 메소드

public getOriginalData ( )

getScenario() 공개 메소드

public getScenario ( )

has() 공개 메소드

public has ( $selector )

hasErrors() 공개 메소드

public hasErrors ( )

isModified() 공개 메소드

public isModified ( $selector = null )

isScenario() 공개 메소드

public isScenario ( $scenario )

isValid() 공개 메소드

check if filled model params is valid
public isValid ( ) : boolean
리턴 boolean

jsonSerialize() 공개 메소드

public jsonSerialize ( )

merge() 공개 메소드

Merge array to current structure with setting modification mark
public merge ( array $data ) : Structure
$data array
리턴 Structure

mergeUnmodified() 공개 메소드

Merge array to current structure without setting modification mark
public mergeUnmodified ( array $data ) : Structure
$data array
리턴 Structure

prepareToStore() 공개 정적인 메소드

public static prepareToStore ( $value )

replace() 공개 메소드

Document became unmodified
public replace ( array $data )
$data array new document data

reset() 공개 메소드

Replace modified fields with original
public reset ( )

rules() 공개 메소드

Validation rules
public rules ( ) : array
리턴 array

set() 공개 메소드

Store value to specified selector in local cache
public set ( string $selector, mixed $value ) : Document
$selector string point-delimited field selector
$value mixed value
리턴 Document

setDataReference() 보호된 메소드

This method allow set data of document in external code. e.g. link data of document to GridFS file matadata. Modification of document's data will modify external data too. Note that also the opposite case also right - modification of external data will modify document's data directly, so document may be in unconsisted state.
protected setDataReference ( array &$data ) : Structure
$data array reference to data in external code
리턴 Structure

setNoScenario() 공개 메소드

public setNoScenario ( )

setScenario() 공개 메소드

public setScenario ( $scenario )

toArray() 공개 메소드

public toArray ( )

triggerError() 공개 메소드

Add custom error which not reset after validation
public triggerError ( type $fieldName, type $ruleName, type $message ) : Document
$fieldName type
$ruleName type
$message type
리턴 Document

triggerErrors() 공개 메소드

Add custom errors
public triggerErrors ( array $errors ) : Document
$errors array
리턴 Document

unsetField() 공개 메소드

public unsetField ( $selector )

프로퍼티 상세

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

사용 중단: use self::$schema to define initial data and getters or setters to get or set field's values.
protected array $_data
리턴 array

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

Initial document's data
protected array $schema
리턴 array