AbstractDaoService<Ta>
Abstract DAO-backed Service
- Copyright
- 2015-2016 Appertly
- License
- Apache-2.0
Instance Properties
| Name | Type | Summary |
|---|---|---|
$gatekeeper | Gatekeeper |
Constructors / Destructors
| Returns | Signature and Description |
|---|---|
void | __construct()Creates a new AbstractDaoService. |
Instance Methods
| Returns | Signature and Description |
|---|---|
int | countAll()Counts several records by some arbitrary criteria. |
Traversable<Ta> | findAll(, , )Finds several records by some arbitrary criteria. |
?Ta | findById()Gets a single document by ID. |
?Ta | findOne()Finds a single record by some arbitrary criteria. |
Ta | get()Gets a single document by ID, throwing an exception if it's not found. |
Traversable<Ta> | getAll()Gets several documents by ID. |
ImmMap<string,Ta> | getInstanceMap()Gets a Map that relates identifier to instance |
string | getType()Gets the type of entity produced, mainly for ACL reasons. |
| Returns | Signature and Description |
|---|---|
Ta | getAndAssert(, )Gets the entity and asserts an ACL permission. |
EntityRepo<Ta> | getDao()Gets the DAO. |
Ta | getForUpdate()Gets the record, but tests the 'write' permission |
Property Details
$gatekeeper
Gatekeeper $gatekeeperMethod Details
__construct
__construct(Gatekeeper $gatekeeper)Creates a new AbstractDaoService.
| Name | Type | Description |
|---|---|---|
$gatekeeper | Gatekeeper | The security gatekeeper |
countAll
countAll(ConstMap<string,mixed> $criteria)Counts several records by some arbitrary criteria.
- Since
- 0.6.0
| Name | Type | Description |
|---|---|---|
$criteria | ConstMap<string,mixed> | Field to value pairs |
| Type | Description |
|---|---|
int | The count of the documents |
| Type | Conditions |
|---|---|
Unreachable | If the connection fails |
Unretrievable | If the result cannot be returned |
Generic | If any other database problem occurs |
findAll
findAll(ConstMap<string,mixed> $criteria, ?Pagination $pagination = null, ?bool $totalCount = false)Finds several records by some arbitrary criteria.
| Name | Type | Description |
|---|---|---|
$criteria | ConstMap<string,mixed> | Field to value pairs |
$pagination | ?Pagination | Optional pagination parameters |
$totalCount | ?bool | Return a |
| Type | Description |
|---|---|
Traversable<Ta> | The objects found or null if none |
| Type | Conditions |
|---|---|
Unreachable | If the connection fails |
Unretrievable | If the result cannot be returned |
Generic | If any other database problem occurs |
findById
findById(mixed $id)Gets a single document by ID.
| Name | Type | Description |
|---|---|---|
$id | mixed | The document identifier |
| Type | Description |
|---|---|
?Ta | The entity |
| Type | Conditions |
|---|---|
Forbidden | If the user has no access |
Unreachable | If the connection fails |
Unretrievable | If the result cannot be returned |
Generic | If any other database problem occurs |
findOne
findOne(ConstMap<string,mixed> $criteria)Finds a single record by some arbitrary criteria.
| Name | Type | Description |
|---|---|---|
$criteria | ConstMap<string,mixed> | Field to value pairs |
| Type | Description |
|---|---|
?Ta | The object found or null if none |
| Type | Conditions |
|---|---|
Unreachable | If the connection fails |
Unretrievable | If the result cannot be returned |
Generic | If any other database problem occurs |
get
get(mixed $id)Gets a single document by ID, throwing an exception if it's not found.
| Name | Type | Description |
|---|---|---|
$id | mixed | The document identifier |
| Type | Description |
|---|---|
Ta | The entity |
| Type | Conditions |
|---|---|
Forbidden | If the user has no access |
Unreachable | If the connection fails |
Unretrievable | If the document doesn't exist |
Generic | If any other database problem occurs |
getAll
getAll(ConstVector<mixed> $ids)Gets several documents by ID.
| Name | Type | Description |
|---|---|---|
$ids | ConstVector<mixed> | Array of identifiers |
| Type | Description |
|---|---|
Traversable<Ta> | The results |
| Type | Conditions |
|---|---|
Forbidden | If the user has no access |
Unreachable | If the connection fails |
Unretrievable | If the result cannot be returned |
Generic | If any other database problem occurs |
getAndAssert
getAndAssert(mixed $id, string $verb)Gets the entity and asserts an ACL permission.
- Since
- 0.5.1
| Name | Type | Description |
|---|---|---|
$id | mixed | The entity id |
$verb | string | The verb (e.g. 'read', 'write') |
| Type | Description |
|---|---|
Ta | The entity |
| Type | Conditions |
|---|---|
Unreachable | If the connection fails |
Unretrievable | If the document doesn't exist |
Generic | If any other database problem occurs |
Forbidden | If the user has no access |
getDao
getDao()Gets the DAO.
| Type | Description |
|---|---|
EntityRepo<Ta> | The backing DAO |
getForUpdate
getForUpdate(mixed $id)Gets the record, but tests the 'write' permission
- Deprecated
- Since 0.5.1. Use `getAndAssert($id, 'write')` instead
- Scheduled for removal in 1.0.0
| Name | Type | Description |
|---|---|---|
$id | mixed | The entity id |
| Type | Description |
|---|---|
Ta | The entity |
| Type | Conditions |
|---|---|
Unreachable | If the connection fails |
Unretrievable | If the document doesn't exist |
Generic | If any other database problem occurs |
Forbidden | If the user has no access |
getInstanceMap
getInstanceMap(Traversable<Ta> $entities)Gets a Map that relates identifier to instance
| Name | Type | Description |
|---|---|---|
$entities | Traversable<Ta> | The entities to "zip" |
| Type | Description |
|---|---|
ImmMap<string,Ta> | The instances keyed by identifier |
getType
getType()Gets the type of entity produced, mainly for ACL reasons.
| Type | Description |
|---|---|
string | The entity type |