Gc\Tab\Model::load PHP Method

load() public method

Initiliaze Tab
public load ( integer $tabId = null, integer $documentTypeId = null ) : Model
$tabId integer Optional tab id
$documentTypeId integer Optional document type id
return Model
    public function load($tabId = null, $documentTypeId = null)
    {
        $this->setId((int) $tabId);
        $this->setDocumentTypeId((int) $documentTypeId);
        $tabId = $this->getId();
        $select = $this->select(function (Select $select) use($documentTypeId, $tabId) {
            if ($documentTypeId !== null) {
                $select->where->equalTo('document_type_id', $documentTypeId);
            }
            if ($tabId !== null) {
                $select->where->equalTo('id', $tabId);
            }
        });
        $row = $this->fetchRow($select);
        if (empty($row['id'])) {
            return false;
        }
        $this->setName($row['name']);
        $this->setDescription($row['description']);
        $this->setDocumentTypeId($row['document_type_id']);
        $this->setSortOrder($row['sort_order']);
        return $this;
    }

Usage Example

Example #1
0
 /**
  * Test
  *
  * @return void
  */
 public function testLoadWithWrongValues()
 {
     $this->assertFalse($this->object->load('undefined'));
 }