PHP Class LeanMapper\Entity

Author: Vojtěch Kohout
Mostra file Open project: tharos/leanmapper Class Usage Examples

Protected Properties

Property Type Description
$entityFactory leanmapper\IEntityFactory
$mapper leanmapper\IMapper
$reflections LeanMapper\Reflection\EntityReflection[]
$row Row

Public Methods

Method Description
__call ( string $name, array $arguments ) : mixed | void
__construct ( Row | Traversabl\Traversable | array | null $arg = null )
__get ( string $name ) : mixed
__isset ( string $name ) : boolean Tells whether given property exists and is not null
__set ( string $name, mixed $value )
__sleep ( ) : array
assign ( array | Traversabl\Traversable $values, array $whitelist = null ) Performs mass value assignment (using setters)
attach ( integer $id ) Attaches entity
detach ( ) Detaches entity
getData ( array $whitelist = null ) : array Gets high-level values of properties
getHasManyRowDifferences ( ) : array Gets current M:N differences
getModifiedRowData ( ) : array Gets low-level values of underlying Row columns that were modified
getReflection ( leanmapper\IMapper $mapper = null ) : EntityReflection Gets reflection of current entity
getRowData ( ) : array Gets low-level values of underlying Row columns
isDetached ( ) : boolean Tells whether entity is in detached state (like newly created entity)
isModified ( ) : boolean Tells whether entity was modified
makeAlive ( leanmapper\IEntityFactory $entityFactory = null, Connection $connection = null, leanmapper\IMapper $mapper = null ) Provides dependencies
markAsUpdated ( ) Marks entity as non-modified (isModified returns false right after this method call)

Protected Methods

Method Description
assignEntityToProperty ( Entity $entity = null, Property | string $property )
createImplicitFilters ( string $entityClass, Caller $caller = null ) : ImplicitFilters
get ( $property, array $filterArgs = [] ) : mixed
getCurrentReflection ( ) : EntityReflection Gets current entity's reflection (cached in memory)
getValueByPropertyWithRelationship ( Property | string $property, Filtering $targetTableFiltering = null, Filtering $relationshipTableFiltering = null ) : Entity | Entity[]
initDefaults ( ) Allows initialize properties' default values
mergeFilters ( array $filters1, array $filters2 ) : array
set ( Property | string $property, mixed $value )

Private Methods

Method Description
addToOrRemoveFrom ( string $action, string $name, mixed $arg )
checkConsistency ( Property $property, string $mapperClass, Entity $entity )
checkMethodArgumentsCount ( integer $expectedCount, array $arguments, string $methodName )
getBelongsToManyValue ( Property $property, LeanMapper\Relationship\BelongsToMany $relationship, Filtering $filtering = null ) : Entity[]
getBelongsToOneValue ( Property $property, LeanMapper\Relationship\BelongsToOne $relationship, Filtering $filtering = null ) : Entity
getHasManyValue ( Property $property, HasMany $relationship, Filtering $targetTableFiltering = null, Filtering $relTableFiltering = null ) : Entity[]
getHasOneValue ( Property $property, HasOne $relationship, Filtering $filtering = null ) : Entity
setEntityFactory ( leanmapper\IEntityFactory $entityFactory )
useMapper ( leanmapper\IMapper $mapper ) Provides an mapper for entity

Method Details

__call() public method

public __call ( string $name, array $arguments ) : mixed | void
$name string
$arguments array
return mixed | void

__construct() public method

public __construct ( Row | Traversabl\Traversable | array | null $arg = null )
$arg Row | Traversabl\Traversable | array | null

__get() public method

public __get ( string $name ) : mixed
$name string
return mixed

__isset() public method

Tells whether given property exists and is not null
public __isset ( string $name ) : boolean
$name string
return boolean

__set() public method

public __set ( string $name, mixed $value )
$name string
$value mixed

__sleep() public method

public __sleep ( ) : array
return array

assign() public method

Performs mass value assignment (using setters)
public assign ( array | Traversabl\Traversable $values, array $whitelist = null )
$values array | Traversabl\Traversable
$whitelist array

assignEntityToProperty() protected method

protected assignEntityToProperty ( Entity $entity = null, Property | string $property )
$entity Entity
$property LeanMapper\Reflection\Property | string micro-optimalization

attach() public method

Attaches entity
public attach ( integer $id )
$id integer

createImplicitFilters() protected method

protected createImplicitFilters ( string $entityClass, Caller $caller = null ) : ImplicitFilters
$entityClass string
$caller Caller
return ImplicitFilters

detach() public method

Detaches entity
public detach ( )

get() protected method

protected get ( $property, array $filterArgs = [] ) : mixed
$property
$filterArgs array
return mixed

getCurrentReflection() protected method

Gets current entity's reflection (cached in memory)
protected getCurrentReflection ( ) : EntityReflection
return LeanMapper\Reflection\EntityReflection

getData() public method

Gets high-level values of properties
public getData ( array $whitelist = null ) : array
$whitelist array
return array

getHasManyRowDifferences() public method

Gets current M:N differences
public getHasManyRowDifferences ( ) : array
return array

getModifiedRowData() public method

Gets low-level values of underlying Row columns that were modified
public getModifiedRowData ( ) : array
return array

getReflection() public static method

Gets reflection of current entity
public static getReflection ( leanmapper\IMapper $mapper = null ) : EntityReflection
$mapper leanmapper\IMapper
return LeanMapper\Reflection\EntityReflection

getRowData() public method

Gets low-level values of underlying Row columns
public getRowData ( ) : array
return array

getValueByPropertyWithRelationship() protected method

protected getValueByPropertyWithRelationship ( Property | string $property, Filtering $targetTableFiltering = null, Filtering $relationshipTableFiltering = null ) : Entity | Entity[]
$property LeanMapper\Reflection\Property | string micro-optimalization
$targetTableFiltering Filtering
$relationshipTableFiltering Filtering
return Entity | Entity[]

initDefaults() protected method

Allows initialize properties' default values
protected initDefaults ( )

isDetached() public method

Tells whether entity is in detached state (like newly created entity)
public isDetached ( ) : boolean
return boolean

isModified() public method

Tells whether entity was modified
public isModified ( ) : boolean
return boolean

makeAlive() public method

Provides dependencies
public makeAlive ( leanmapper\IEntityFactory $entityFactory = null, Connection $connection = null, leanmapper\IMapper $mapper = null )
$entityFactory leanmapper\IEntityFactory
$connection Connection
$mapper leanmapper\IMapper

markAsUpdated() public method

Marks entity as non-modified (isModified returns false right after this method call)
public markAsUpdated ( )

mergeFilters() protected method

protected mergeFilters ( array $filters1, array $filters2 ) : array
$filters1 array
$filters2 array
return array

set() protected method

protected set ( Property | string $property, mixed $value )
$property LeanMapper\Reflection\Property | string
$value mixed

Property Details

$entityFactory protected_oe property

protected IEntityFactory,leanmapper $entityFactory
return leanmapper\IEntityFactory

$mapper protected_oe property

protected IMapper,leanmapper $mapper
return leanmapper\IMapper

$reflections protected_oe static_oe property

protected static EntityReflection[],LeanMapper\Reflection $reflections
return LeanMapper\Reflection\EntityReflection[]

$row protected_oe property

protected Row,leanmapper $row
return Row