PHP Класс Mongolid\Model\DocumentEmbedder

Показать файл Открыть проект

Открытые методы

Метод Описание
attach ( mixed $parent, string $field, object | array &$entity ) : boolean Attach a new _id reference into $field of $parent.
detach ( mixed $parent, string $field, mixed &$entity ) : boolean Removes an _id reference from $field of $parent.
embed ( mixed $parent, string $field, mixed &$entity ) : boolean Embeds the given $entity into $field of $parent. This method will also consider the _id of the $entity in order to update it if it is already present in $field.
unembed ( mixed $parent, string $field, mixed &$entity ) : boolean Removes the given $entity from $field of $parent. This method will consider the _id of the $entity in order to remove it.

Защищенные методы

Метод Описание
getId ( mixed &$object ) : MongoDB\BSON\ObjectID | mixed Gets the _id of the given object or array. If there is no _id in it a new _id will be generated and set on the object (while still returning it).

Описание методов

attach() публичный метод

Attach a new _id reference into $field of $parent.
public attach ( mixed $parent, string $field, object | array &$entity ) : boolean
$parent mixed The object where $entity will be referenced.
$field string The field where the _id reference of $entity will be stored.
$entity object | array The object that is being attached.
Результат boolean Success

detach() публичный метод

Removes an _id reference from $field of $parent.
public detach ( mixed $parent, string $field, mixed &$entity ) : boolean
$parent mixed The object where $entity reference will be removed.
$field string The field where the _id reference of $entity is stored.
$entity mixed The object being detached or its _id.
Результат boolean Success

embed() публичный метод

Embeds the given $entity into $field of $parent. This method will also consider the _id of the $entity in order to update it if it is already present in $field.
public embed ( mixed $parent, string $field, mixed &$entity ) : boolean
$parent mixed The object where the $entity will be embedded.
$field string Name of the field of the object where the document will be embedded.
$entity mixed Entity that will be embedded within $parent.
Результат boolean Success

getId() защищенный метод

Gets the _id of the given object or array. If there is no _id in it a new _id will be generated and set on the object (while still returning it).
protected getId ( mixed &$object ) : MongoDB\BSON\ObjectID | mixed
$object mixed The object|array that the _id will be retrieved from.
Результат MongoDB\BSON\ObjectID | mixed

unembed() публичный метод

Removes the given $entity from $field of $parent. This method will consider the _id of the $entity in order to remove it.
public unembed ( mixed $parent, string $field, mixed &$entity ) : boolean
$parent mixed The object where the $entity will be removed.
$field string Name of the field of the object where the document is.
$entity mixed Entity that will be removed from $parent.
Результат boolean Success