Pimcore\Model\Document\DocType::getById PHP Method

getById() public static method

Static helper to retrieve an instance of Document\DocType by the given ID
public static getById ( integer $id ) : DocType
$id integer
return DocType
    public static function getById($id)
    {
        $docType = new self();
        $docType->setId(intval($id));
        try {
            $docType->getDao()->getById();
        } catch (\Exception $e) {
            return null;
        }
        return $docType;
    }

Usage Example

 /**
  * Loads a list of document-types for the specicifies parameters, returns an array of Document\DocType elements
  *
  * @return array
  */
 public function load()
 {
     $docTypesData = $this->db->fetchCol("SELECT id FROM documents_doctypes" . $this->getCondition() . $this->getOrder() . $this->getOffsetLimit(), $this->model->getConditionVariables());
     $docTypes = array();
     foreach ($docTypesData as $docTypeData) {
         $docTypes[] = Model\Document\DocType::getById($docTypeData);
     }
     $this->model->setDocTypes($docTypes);
     return $docTypes;
 }
All Usage Examples Of Pimcore\Model\Document\DocType::getById