PHP Class LeanMapper\Repository

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

Protected Properties

Property Type Description
$connection Connection
$entityClass string
$entityFactory leanmapper\IEntityFactory
$events Events
$mapper leanmapper\IMapper
$table string

Public Methods

Method Description
__construct ( Connection $connection, leanmapper\IMapper $mapper, leanmapper\IEntityFactory $entityFactory )
__get ( string $name ) : array | null
delete ( mixed $arg ) : mixed Removes given entity (or entity with given id) from database
persist ( Entity $entity ) : mixed Stores values of entity's modified properties into database (inserts new row when entity is in detached state)

Protected Methods

Method Description
checkEntityType ( Entity $entity ) Checks whether give entity is instance of required type
createEntities ( array $rows, string | null $entityClass = null, string | null $table = null ) : array Creates new set of Entity's instances from given array of \Dibi\Row instances
createEntity ( Row $dibiRow, string | null $entityClass = null, string | null $table = null ) : mixed Creates new Entity instance from given \Dibi\Row instance
createFluent ( ) : Fluent
deleteFromDatabase ( mixed $arg ) : mixed Performs database delete (can be customized)
getTable ( ) : string Gets name of (main) database table related to entity that repository can handle
initEvents ( ) Allows initialize repository's events
insertIntoDatabase ( Entity $entity ) : mixed Performs database insert (can be customized)
persistHasManyChanges ( Entity $entity ) Persists changes in M:N relationships
updateInDatabase ( Entity $entity ) : mixed Performs database update (can be customized)

Private Methods

Method Description
getDocComment ( ) : string
getIdValue ( Entity $entity ) : mixed

Method Details

__construct() public method

public __construct ( Connection $connection, leanmapper\IMapper $mapper, leanmapper\IEntityFactory $entityFactory )
$connection Connection
$mapper leanmapper\IMapper
$entityFactory leanmapper\IEntityFactory

__get() public method

public __get ( string $name ) : array | null
$name string
return array | null

checkEntityType() protected method

Checks whether give entity is instance of required type
protected checkEntityType ( Entity $entity )
$entity Entity

createEntities() protected method

Creates new set of Entity's instances from given array of \Dibi\Row instances
protected createEntities ( array $rows, string | null $entityClass = null, string | null $table = null ) : array
$rows array
$entityClass string | null
$table string | null
return array

createEntity() protected method

Creates new Entity instance from given \Dibi\Row instance
protected createEntity ( Row $dibiRow, string | null $entityClass = null, string | null $table = null ) : mixed
$dibiRow Dibi\Row
$entityClass string | null
$table string | null
return mixed

createFluent() protected method

protected createFluent ( ) : Fluent
return Fluent

delete() public method

Removes given entity (or entity with given id) from database
public delete ( mixed $arg ) : mixed
$arg mixed
return mixed

deleteFromDatabase() protected method

Performs database delete (can be customized)
protected deleteFromDatabase ( mixed $arg ) : mixed
$arg mixed
return mixed

getTable() protected method

Gets name of (main) database table related to entity that repository can handle
protected getTable ( ) : string
return string

initEvents() protected method

Allows initialize repository's events
protected initEvents ( )

insertIntoDatabase() protected method

Performs database insert (can be customized)
protected insertIntoDatabase ( Entity $entity ) : mixed
$entity Entity
return mixed

persist() public method

Stores values of entity's modified properties into database (inserts new row when entity is in detached state)
public persist ( Entity $entity ) : mixed
$entity Entity
return mixed

persistHasManyChanges() protected method

Persists changes in M:N relationships
protected persistHasManyChanges ( Entity $entity )
$entity Entity

updateInDatabase() protected method

Performs database update (can be customized)
protected updateInDatabase ( Entity $entity ) : mixed
$entity Entity
return mixed

Property Details

$connection protected property

protected Connection,leanmapper $connection
return Connection

$entityClass protected property

protected string $entityClass
return string

$entityFactory protected property

protected IEntityFactory,leanmapper $entityFactory
return leanmapper\IEntityFactory

$events protected property

protected Events,leanmapper $events
return Events

$mapper protected property

protected IMapper,leanmapper $mapper
return leanmapper\IMapper

$table protected property

protected string $table
return string