/** * @param $record * * @return array * @throws Exception */ public function getConfig($configTypeName, $workspace = 'default', $language = 'default', $timeshift = 0) { $configTypeDefinition = $this->repository->getConfigTypeDefinition($configTypeName); if ($configTypeDefinition) { $repositoryName = $this->repository->getName(); $configTypeName = $configTypeDefinition->getName(); $tableName = $repositoryName . '$$config'; if ($tableName != Util::generateValidIdentifier($repositoryName) . '$$config') { throw new RepositoryException('Invalid repository and/or config type name(s).'); } $dbh = $this->repository->getDatabaseConnection(); $timestamp = $this->repository->getTimeshiftTimestamp($timeshift); $sql = 'SELECT * FROM ' . $tableName . ' WHERE id = ? AND workspace = ? AND language = ? AND validfrom_timestamp <= ? AND validuntil_timestamp > ?'; $stmt = $dbh->prepare($sql); $params = array(); $params[] = $configTypeName; $params[] = $workspace; $params[] = $language; $params[] = $timestamp; $params[] = $timestamp; try { $stmt->execute($params); $row = $stmt->fetch(\PDO::FETCH_ASSOC); if ($row) { $record = array(); $record['id'] = $configTypeName; $properties = json_decode($row['properties'], true); $record['properties'] = $properties; $record['info'] = array(); $record['info']['revision'] = $row['revision']; $record['info']['revision_timestamp'] = $row['validfrom_timestamp']; $record['info']['hash'] = $row['hash']; $info = array(); $info['repository'] = $repositoryName; $info['config_type'] = $configTypeName; $info['workspace'] = $workspace; $info['language'] = $language; $record['info']['lastchange']['timestamp'] = $row['lastchange_timestamp']; $record['info']['lastchange']['username'] = $row['lastchange_username']; $record['info']['lastchange']['firstname'] = $row['lastchange_firstname']; $record['info']['lastchange']['lastname'] = $row['lastchange_lastname']; return array('info' => $info, 'record' => $record); } else { return false; } } catch (\PDOException $e) { return false; } } return false; }