id = (int)$instanceRow['id']; $instanceConfig->namespace = $instanceRow['namespace']; $instanceConfig->rootNamespace = $instanceRow['rootNamespace']; $instanceConfig->source = $instanceRow['SOURCE']; $instanceConfig->status = $instanceRow['A_STATUS']; $instanceConfig->version = $instanceRow['VERSION']; $instanceConfig->tableName = self::generateTableName($instanceConfig->id, $instanceConfig->source); return $instanceConfig; } static function generateTableName($id, $source) { // @return string | null switch ($source) { case 'table': return "CRM__#INSTANCE_TABLE__{$id}"; case 'view': return "CRM__#INSTANCE_TABLE__{$id}_VIEW"; default: throw new Exception("Not Implemented instance source '{$source}'"); } } function __isset($name) { return (array_key_exists($name, $this->_data)); } function __get($name) { if (array_key_exists($name, $this->_data)) { return $this->_data[$name]; } return null; } function __set($name, $value) { $this->_data[$name] = $value; } function toArray() { return $this->_data; } function __toString() { return str_replace('"', '', str_replace([ '{', '}', '":', ',"' ], [ '{ ', ' }', ': ', ', ' ], json_encode($this->_data)) ); } }