Mongolid\Model\DocumentEmbedder::embed PHP Метод

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
    public function embed($parent, string $field, &$entity) : bool
    {
        // In order to update the document if it exists inside the $parent
        $this->unembed($parent, $field, $entity);
        $fieldValue = $parent->{$field};
        $fieldValue[] = $entity;
        $parent->{$field} = array_values($fieldValue);
        return true;
    }