Gc\Document\Collection::setDocuments PHP Method

setDocuments() protected method

Initialize documents
protected setDocuments ( ) : Collection
return Collection
    protected function setDocuments()
    {
        $parentId = $this->getParentId();
        $rows = $this->fetchAll($this->select(function (Select $select) use($parentId) {
            if (empty($parentId)) {
                $select->where->isNull('parent_id');
            } else {
                $select->where->equalTo('parent_id', $parentId);
            }
            $select->order('sort_order ASC');
            $select->order('created_at ASC');
        }));
        $documents = array();
        foreach ($rows as $row) {
            $documents[] = Model::fromArray((array) $row);
        }
        $this->setData('documents', $documents);
        return $this;
    }