Gc\DocumentType\Collection::setDocumentTypes PHP Method

setDocumentTypes() protected method

Initialize document types
protected setDocumentTypes ( ) : Collection
return Gc\Document\Collection
    protected function setDocumentTypes()
    {
        $parentId = $this->getParentId();
        $rows = $this->fetchAll($this->select(function (Select $select) use($parentId) {
            if ($parentId !== null) {
                $select->join(array('dtd' => 'document_type_dependency'), 'dtd.children_id = document_type.id', array());
                $select->where->equalTo('dtd.parent_id', $parentId);
            }
            $select->order('name ASC');
        }));
        $documentTypes = array();
        foreach ($rows as $row) {
            $documentTypes[] = Model::fromArray((array) $row);
        }
        $this->setData('document_types', $documentTypes);
    }