Gc\Tab\Model::fromId PHP Method

fromId() public static method

Initialize from id
public static fromId ( integer $tabId ) : Model
$tabId integer Tab id
return Model
    public static function fromId($tabId)
    {
        $tabTable = new Model();
        $row = $tabTable->fetchRow($tabTable->select(array('id' => (int) $tabId)));
        $tabTable->events()->trigger(__CLASS__, 'before.load', $tabTable);
        if (!empty($row)) {
            $tabTable->setData((array) $row);
            $tabTable->setOrigData();
            $tabTable->events()->trigger(__CLASS__, 'after.load', $tabTable);
            return $tabTable;
        } else {
            $tabTable->events()->trigger(__CLASS__, 'after.load.failed', $tabTable);
            return false;
        }
    }

Usage Example

Esempio n. 1
0
 /**
  * Add tab in session
  *
  * @return \Zend\View\Model\JsonModel
  */
 public function importTabAction()
 {
     if (!$this->getRequest()->isPost()) {
         return $this->returnJson(array('success' => false, 'message' => 'Error'));
     }
     $tabId = $this->getRequest()->getPost()->get('tab_id');
     $tabModel = Tab\Model::fromId($tabId);
     $propertiesList = $tabModel->getProperties();
     $properties = array();
     foreach ($propertiesList as $property) {
         $properties[] = array('name' => $property->getName(), 'identifier' => $property->getIdentifier(), 'description' => $property->getDescription(), 'datatype' => $property->getDatatypeId(), 'isRequired' => $property->isRequired());
     }
     $tab = array('name' => $tabModel->getName(), 'description' => $tabModel->getDescription(), 'properties' => $properties);
     return $this->returnJson(array('success' => true, 'tab' => $tab));
 }
All Usage Examples Of Gc\Tab\Model::fromId