/** * @inheritdoc */ public function getMeta($id) { if (!empty($this->driver[$id])) { return Type::getType($this->driver[$id]); } return false; }
/** * Merge local attributes and db attributes * * @access protected * * @return array * @throws \Micro\base\Exception */ protected function mergeAttributesDb() { $arr = Type::getVars($this); $buffer = []; foreach ($this->container->db->listFields(static::tableName()) as $row) { $buffer[] = $row['field']; } foreach ($arr as $key => $val) { if (!in_array($key, $buffer, true)) { unset($arr[$key]); } } unset($arr['isNewRecord']); return $arr; }
/** * Initialize widget * * @access public * * @result void */ public function init() { $this->filterPrefix = ucfirst($this->filterPrefix ?: 'data' . $this->totalCount); $this->fields = null !== $this->rows ? array_keys(Type::getVars($this->rows[0])) : []; $this->rowsCount = count($this->rows); $this->paginationConfig['countRows'] = $this->totalCount; $this->paginationConfig['limit'] = $this->limit; $this->paginationConfig['currentPage'] = $this->page; $this->tableConfig = $this->tableConfig ?: $this->fields; foreach ($this->tableConfig as $key => $conf) { unset($this->tableConfig[$key]); $this->tableConfig[is_string($conf) ? $conf : $key] = array_merge(['attributesHeader' => !empty($conf['attributesHeader']) ? $conf['attributesHeader'] : [], 'attributesFilter' => !empty($conf['attributesFilter']) ? $conf['attributesFilter'] : [], 'attributes' => !empty($conf['attributes']) ? $conf['attributes'] : []], is_array($conf) ? $conf : []); } }