Gc\Layout\Model::fromId PHP Method

fromId() public static method

Initiliaze from id
public static fromId ( integer $layoutId ) : Model
$layoutId integer Layout id
return Model
    public static function fromId($layoutId)
    {
        $layoutTable = new Model();
        $row = $layoutTable->fetchRow($layoutTable->select(array('id' => (int) $layoutId)));
        $layoutTable->events()->trigger(__CLASS__, 'before.load', $layoutTable);
        if (!empty($row)) {
            $layoutTable = self::fromArray((array) $row);
            $layoutTable->events()->trigger(__CLASS__, 'after.load', $layoutTable);
            return $layoutTable;
        } else {
            $layoutTable->events()->trigger(__CLASS__, 'after.load.failed', $layoutTable);
            return false;
        }
    }

Usage Example

示例#1
0
文件: Model.php 项目: gotcms/gotcms
 /**
  * get View Model
  *
  * @return \Gc\View\Model
  */
 public function getLayout()
 {
     if ($this->getData('layout') == null) {
         $view = Layout\Model::fromId($this->getLayoutId());
         if ($view !== null) {
             $this->setData('layout', $view);
         }
     }
     return $this->getData('layout');
 }
All Usage Examples Of Gc\Layout\Model::fromId