Gc\DocumentType\Model::fromId PHP Method

fromId() public static method

Get model from id
public static fromId ( integer $documentTypeId ) : Model
$documentTypeId integer Document type id
return 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;
        }
    }

Usage Example

Example #1
0
 /**
  * Load tabs from document type
  *
  * @param integer $documentTypeId Document type id
  *
  * @return array
  */
 public function loadTabs($documentTypeId)
 {
     if (empty($this->tabs[$documentTypeId])) {
         $documentType = DocumentType\Model::fromId($documentTypeId);
         $tabs = $documentType->getTabs();
         $this->tabs[$documentTypeId] = $tabs;
     }
     return $this->tabs[$documentTypeId];
 }
All Usage Examples Of Gc\DocumentType\Model::fromId