fromId() public static method

Initiliaze from id
public static fromId ( integer $iconId ) : Model
$iconId integer Icon id
return Model
コード例 #1
0
ファイル: Collection.php プロジェクト: gotcms/gotcms
 /**
  * Get views
  *
  * @param boolean $forceReload to initiliaze views
  *
  * @return array
  */
 public function getIcons($forceReload = false)
 {
     if ($forceReload) {
         $rows = $this->fetchAll($this->select(function (Select $select) {
             $select->order('name');
         }));
         $array = array();
         foreach ($rows as $row) {
             $array[] = Model::fromId($row['id']);
         }
         $this->setData('icons', $array);
     }
     return $this->getData('icons');
 }
コード例 #2
0
ファイル: ModelTest.php プロジェクト: gotcms/gotcms
 /**
  * Test
  *
  * @return void
  */
 public function testFromWithWrongId()
 {
     $this->assertFalse(Model::fromId('undefined'));
 }
コード例 #3
0
ファイル: Model.php プロジェクト: gotcms/gotcms
 /** (non-PHPdoc)
  *
  * @see include \Gc\Component\IterableInterface#getIcon()
  * @return mixed
  */
 public function getIcon()
 {
     if ($this->getData('icon') === null) {
         $icon = Icon\Model::fromId($this->getDocumentType()->getIconId());
         if (empty($icon)) {
             return false;
         }
         $this->setData('icon', $icon->getUrl());
     }
     return $this->getData('icon');
 }