ChildrenAdapter
in package
implements
ArrayAccess, Iterator, AdapterInterface
Children refers to all models that refer to another (parent) model. This allows to manage Relational databases like they're documents.
Tags
Interfaces, Classes and Traits
- ArrayAccess
- Iterator
- AdapterInterface
- An adapter is basically a simple block that contains receives and delivers data both to the user and the database. This turns it into a great tool to sanitize user data and prepare information from the DB in a way that it's user friendly.
Table of Contents
- $children : array<string|int, Model>|null
- The models that refer to the parent model. This can be either an array of models or null, depending on whether the adapter has been populated during runtime.
- $discarded : mixed
- $field : ChildrenField
- The field the parent uses to refer to this element.
- $parent : Model
- The model that this one refers to. Since, one Model can have several referring to it but a model can only refer to one other, we call this model parent.
- __construct() : mixed
- __toString() : mixed
- commit() : type
- Settles the content inside the adapter. This method is usually called when the model is being stored. This means the data is considered final and the data inside the adapter is no longer out of sync with the database.
- current() : mixed
- dbGetData() : mixed
- This method returns the data the adapter wants to store to the database. The DBMS controller should use this endpoint to collect the data it will store to the driver.
- dbSetData() : mixed
- This method does nothing as this field has no direct data in the DBMS and therefore it just ignores whatever the database tries to input.
- getField() : Field
- Returns the field this adapter holds data for. This is important for the database driver as it will have to locate the field where it has to place this data.
- getModel() : Model
- Returns the parent model for this adapter. This allows any application to trace what adapter this adapter belongs to.
- getQuery() : Query
- Returns the query that would be used to retrieve the elements for this adapter. This can be used to add restrictions and query the related records
- isSynced() : bool
- Allows the adapter to tell the database driver whether the data inside this is synced (has not been modified) and should be stored to the database to avoid being lost.
- key() : mixed
- next() : mixed
- offsetExists() : mixed
- offsetGet() : mixed
- offsetSet() : mixed
- offsetUnset() : mixed
- pluck() : Model
- rewind() : mixed
- rollback() : mixed
- Resets the content inside the adapter. In case you don't want to keep the altered data and want to modify or read the original source data instead of the altered one.
- toArray() : mixed
- usrGetData() : mixed
- Returns the data that is meant to reach the 'user space'. Objects here should be programmer friendly and can be objects if needed.
- usrSetData() : mixed
- Defines the data inside this adapter. In case the user is trying to set this adapter as the source for itself, which can happen in case the user is reading the adapter and expecting himself to save it back this function will do nothing.
- valid() : mixed
Properties
$children
The models that refer to the parent model. This can be either an array of models or null, depending on whether the adapter has been populated during runtime.
private
array<string|int, Model>|null
$children
$discarded
private
mixed
$discarded
= []
$field
The field the parent uses to refer to this element.
private
ChildrenField
$field
$parent
The model that this one refers to. Since, one Model can have several referring to it but a model can only refer to one other, we call this model parent.
private
Model
$parent
Methods
__construct()
public
__construct(ChildrenField $field, Model $model[, mixed $data = null ]) : mixed
Parameters
- $field : ChildrenField
- $model : Model
- $data : mixed = null
Return values
mixed —__toString()
public
__toString() : mixed
Return values
mixed —commit()
Settles the content inside the adapter. This method is usually called when the model is being stored. This means the data is considered final and the data inside the adapter is no longer out of sync with the database.
public
commit() : type
Return values
type —current()
public
current() : mixed
Return values
mixed —dbGetData()
This method returns the data the adapter wants to store to the database. The DBMS controller should use this endpoint to collect the data it will store to the driver.
public
dbGetData() : mixed
Return values
mixed —Data to be contained in the database.
dbSetData()
This method does nothing as this field has no direct data in the DBMS and therefore it just ignores whatever the database tries to input.
public
dbSetData(mixed $data) : mixed
Parameters
- $data : mixed
Return values
mixed —getField()
Returns the field this adapter holds data for. This is important for the database driver as it will have to locate the field where it has to place this data.
public
getField() : Field
Return values
Field —The field this represents
getModel()
Returns the parent model for this adapter. This allows any application to trace what adapter this adapter belongs to.
public
getModel() : Model
Return values
Model —getQuery()
Returns the query that would be used to retrieve the elements for this adapter. This can be used to add restrictions and query the related records
public
getQuery() : Query
Return values
Query —isSynced()
Allows the adapter to tell the database driver whether the data inside this is synced (has not been modified) and should be stored to the database to avoid being lost.
public
isSynced() : bool
If data considers itself non-DB friendly (like arrays / subrecords /etc) these should return false always and use the commit method to store the data.
Return values
bool —Indicates whether the data is already in sync. Returns false if it should be stored.
key()
public
key() : mixed
Return values
mixed —next()
public
next() : mixed
Return values
mixed —offsetExists()
public
offsetExists(mixed $offset) : mixed
Parameters
- $offset : mixed
Return values
mixed —offsetGet()
public
offsetGet(mixed $offset) : mixed
Parameters
- $offset : mixed
Return values
mixed —offsetSet()
public
offsetSet(mixed $offset, mixed $value) : mixed
Parameters
- $offset : mixed
- $value : mixed
Return values
mixed —offsetUnset()
public
offsetUnset(mixed $offset) : mixed
Parameters
- $offset : mixed
Return values
mixed —pluck()
public
pluck() : Model
Tags
Return values
Model —rewind()
public
rewind() : mixed
Return values
mixed —rollback()
Resets the content inside the adapter. In case you don't want to keep the altered data and want to modify or read the original source data instead of the altered one.
public
rollback() : mixed
Return values
mixed —toArray()
public
toArray() : mixed
Return values
mixed —usrGetData()
Returns the data that is meant to reach the 'user space'. Objects here should be programmer friendly and can be objects if needed.
public
usrGetData() : mixed
You should avoid making verifications / parsing the data in this function, stuff you think should go here probably belongs in dbSetData()
Return values
mixed —Data to be delivered to the programmer
usrSetData()
Defines the data inside this adapter. In case the user is trying to set this adapter as the source for itself, which can happen in case the user is reading the adapter and expecting himself to save it back this function will do nothing.
public
usrSetData(ManyToManyAdapter|array<string|int, Model> $data) : mixed
Parameters
- $data : ManyToManyAdapter|array<string|int, Model>
Tags
Return values
mixed —valid()
public
valid() : mixed