Example #1
0
 /**
  * Get model from id
  *
  * @param integer $documentTypeId Document type id
  *
  * @return \Gc\DocumentType\Model
  */
 public static function fromId($documentTypeId)
 {
     $documentTypeTable = new Model();
     $row = $documentTypeTable->fetchRow($documentTypeTable->select(array('id' => (int) $documentTypeId)));
     $documentTypeTable->events()->trigger(__CLASS__, 'before.load', $documentTypeTable);
     if (!empty($row)) {
         $documentTypeTable->setData((array) $row);
         $documentTypeTable->setOrigData();
         $documentTypeTable->events()->trigger(__CLASS__, 'after.load', $documentTypeTable);
         return $documentTypeTable;
     } else {
         $documentTypeTable->events()->trigger(__CLASS__, 'after.load.failed', $documentTypeTable);
         return false;
     }
 }