Nextcloud PHP API (master)

Repository
in package

Tags
template
since
35.0.0

Table of Contents

Constants

entityClass  : string = ''
The class this repository holds.

Properties

$connection  : IDBConnection
$entityManager  : EntityManager
$entityClassOverride  : string|null

Methods

delete()  : void
deleteBy()  : int
findBy()  : Generator<string|int, T>
Finds entities by a set of criteria, keyed by property name.
findOneBy()  : T
Finds a single entity by a set of criteria, keyed by property name.
getTableName()  : string
insert()  : T
Inserts the entity and populates its generated primary key.
insertOrUpdate()  : T
Tries to create a new entry in the db from an entity and updates an existing entry if duplicate keys are detected by the database
update()  : T
yieldAll()  : Generator<string|int, T>
buildDebugMessage()  : string
buildJoinedSelectQuery()  : EntityInfo}>}
Builds a select query resolving OneToOne and ManyToOne relations via a LEFT JOIN.
findJoinedEntity()  : T
getEntityClass()  : class-string
getJoinedSelectQueryBuilder()  : EntityInfo}>}
hydrateRow()  : S
Builds an entity from a flat row of its own scalar columns. OneToOne relations are always left null here; resolving them is mapJoinedRowToEntity()'s job.
isGeneratedIdColumn()  : bool
joinRelation()  : void
mapJoinedRowToEntity()  : T
yieldJoinedEntities()  : Generator<string|int, T>

Constants

entityClass

The class this repository holds.

public string entityClass = ''
Tags
since
35.0.0
psalm-suppress

InvalidConstantAssignmentValue

Properties

$entityManager read-only

protected EntityManager $entityManager

$entityClassOverride read-only

private string|null $entityClassOverride = null

Methods

delete()

public delete(object $entity) : void
Parameters
$entity : object
Tags
psalm-param

T $entity

since
35.0.0

deleteBy()

public deleteBy(array<string, int|float|string|null|DateTime|array<int, int|float|string>> $criteria[, int|null $limit = null ]) : int
Parameters
$criteria : array<string, int|float|string|null|DateTime|array<int, int|float|string>>
$limit : int|null = null
Tags
throws
Exception
since
35.0.0
Return values
int

The number of rows deleted

findBy()

Finds entities by a set of criteria, keyed by property name.

public findBy(array<string, int|float|string|null|DateTime|array<int, int|float|string>> $criteria[, array<string, SortDirection$orderBy = [] ][, int|null $limit = null ][, int|null $offset = null ]) : Generator<string|int, T>
Parameters
$criteria : array<string, int|float|string|null|DateTime|array<int, int|float|string>>
$orderBy : array<string, SortDirection> = []
$limit : int|null = null
$offset : int|null = null
Tags
since
35.0.0
Return values
Generator<string|int, T>

findOneBy()

Finds a single entity by a set of criteria, keyed by property name.

public findOneBy(array<string, int|float|string|null|DateTime|array<int, int|float|string>> $criteria[, array<string, SortDirection$orderBy = [] ]) : T
Parameters
$criteria : array<string, int|float|string|null|DateTime|array<int, int|float|string>>
$orderBy : array<string, SortDirection> = []
Tags
throws
DoesNotExistException
since
35.0.0
Return values
T

getTableName()

public getTableName() : string
Tags
since
35.0.0
Return values
string

insert()

Inserts the entity and populates its generated primary key.

public insert(object $entity) : T
Parameters
$entity : object
Tags
psalm-param

T $entity

throws
Exception
since
35.0.0
Return values
T

insertOrUpdate()

Tries to create a new entry in the db from an entity and updates an existing entry if duplicate keys are detected by the database

public insertOrUpdate(T $entity) : T
Parameters
$entity : T

the entity that should be created/updated

Tags
throws
Exception
InvalidArgumentException

if entity has no id

since
15.0.0
Return values
T

the saved entity with the (new) id

update()

public update(object $entity) : T
Parameters
$entity : object
Tags
psalm-param

T $entity

since
35.0.0
Return values
T

yieldAll()

public yieldAll() : Generator<string|int, T>
Tags
throws
Exception
since
35.0.0
Return values
Generator<string|int, T>

buildJoinedSelectQuery()

Builds a select query resolving OneToOne and ManyToOne relations via a LEFT JOIN.

private buildJoinedSelectQuery(EntityInfo $entityInfo) : EntityInfo}>}

Columns are aliased e_<column> (main entity) and r<index>_<column> (each relation) to stay unique even when tables share column names.

Parameters
$entityInfo : EntityInfo
Return values
EntityInfo}>}

getEntityClass()

private getEntityClass() : class-string
Return values
class-string

getJoinedSelectQueryBuilder()

private getJoinedSelectQueryBuilder(array<string, int|float|string|null|DateTime|array<int, int|float|string>> $criteria[, array<string, SortDirection$orderBy = [] ]) : EntityInfo}>}
Parameters
$criteria : array<string, int|float|string|null|DateTime|array<int, int|float|string>>
$orderBy : array<string, SortDirection> = []
Return values
EntityInfo}>}

hydrateRow()

Builds an entity from a flat row of its own scalar columns. OneToOne relations are always left null here; resolving them is mapJoinedRowToEntity()'s job.

private hydrateRow(S> $entityClass, array<string, mixed> $row) : S
Parameters
$entityClass : S>
$row : array<string, mixed>
Tags
template
Return values
S

isGeneratedIdColumn()

private isGeneratedIdColumn(EntityInfo $entityInfo, string $column) : bool
Parameters
$entityInfo : EntityInfo
$column : string
Return values
bool

joinRelation()

private joinRelation(IQueryBuilder $qb, string $alias, EntityInfo $targetEntityInfo, string $leftExpr, string $rightExpr) : void
Parameters
$qb : IQueryBuilder
$alias : string
$targetEntityInfo : EntityInfo
$leftExpr : string
$rightExpr : string

mapJoinedRowToEntity()

private mapJoinedRowToEntity(array<string, EntityInfo}$relations, array<string, mixed> $row) : T
Parameters
$relations : array<string, EntityInfo}>
$row : array<string, mixed>
Return values
T

yieldJoinedEntities()

private yieldJoinedEntities(IQueryBuilder $query, array<string, EntityInfo}$relations) : Generator<string|int, T>
Parameters
$query : IQueryBuilder
$relations : array<string, EntityInfo}>
Return values
Generator<string|int, T>
On this page

Search results