Mongolid\Model\Relations::embedsMany PHP Метод

embedsMany() защищенный Метод

Return array of embedded documents as objects.
protected embedsMany ( string $entity, string $field ) : EmbeddedCursor
$entity string Class of the entity or of the schema of the entity.
$field string Field where the embedded documents are stored.
Результат Mongolid\Cursor\EmbeddedCursor Array with the embedded documents
    protected function embedsMany(string $entity, string $field)
    {
        if (is_subclass_of($entity, Schema::class)) {
            $entity = (new $entity())->entityClass;
        }
        $items = (array) $this->{$field};
        if (false === empty($items) && false === array_key_exists(0, $items)) {
            $items = [$items];
        }
        return Ioc::make(CursorFactory::class)->createEmbeddedCursor($entity, $items);
    }