/** * remove protected properties and execute @name annotation * * @param Record $record */ protected function finalizeRecord(Record $record, DataDimensions $dataDimensions) { // Apply @name annotation if ($record->getDataTypeDefinition()->hasNamingPattern()) { $record->setName(Util::applyNamingPattern($record->getProperties(), $record->getDataTypeDefinition()->getNamingPattern())); } // remove protected properties $properties = $record->getProperties(); foreach ($record->getDataTypeDefinition()->getProtectedProperties($dataDimensions->getViewName()) as $property) { unset($properties[$property]); } $record->setProperties($properties); return $record; }
protected function createConfigFromRow($row, $configTypeName, DataDimensions $dataDimensions) { $definition = $this->getConfigTypeDefinition($configTypeName); $config = $this->getRecordFactory()->createConfig($definition, [], $dataDimensions->getViewName(), $dataDimensions->getWorkspace(), $dataDimensions->getLanguage()); $multiViewProperties = json_decode($row['properties'], true); $properties = []; foreach ($definition->getProperties($dataDimensions->getViewName()) as $property) { if (array_key_exists($property, $multiViewProperties)) { $properties[$property] = $multiViewProperties[$property]; } } $config->setProperties($properties); $config->setRevision($row['revision']); $userInfo = new UserInfo($row['lastchange_username'], $row['lastchange_firstname'], $row['lastchange_lastname'], $row['lastchange_timestamp']); $config->setLastChangeUserInfo($userInfo); return $config; }
protected function requestRecords($contentTypeName, DataDimensions $dataDimensions, $filter, $page = 1, $count = null, $order = ['.id']) { $url = 'content/' . $contentTypeName . '/records/' . $dataDimensions->getWorkspace() . '/' . $dataDimensions->getViewName() . '?language=' . $dataDimensions->getLanguage() . '&view=' . $dataDimensions->getViewName() . '×hift=' . $dataDimensions->getTimeShift(); if ($count != null) { $url .= '&page=' . $page . '&limit=' . $count; } if ($filter) { // V1 compatibility $filter = str_replace('*=', '><', (string) $filter); $url .= '&filter=' . urlencode($filter); } // V1 compatibility - multi sort is not possible $map = ['.id' => 'id', '.id-' => 'id', 'position' => 'pos', 'position-' => 'pos-', '.info.creation.timestamp' => 'creation', '.info.creation.timestamp-' => 'creation-', '.info.lastchange.timestamp' => 'change', '.info.lastchange.timestamp-' => 'change-']; if (is_array($order)) { $order = reset($order); if (array_key_exists($order, $map)) { $order = $map[$order]; } } $url .= '&order=' . $order; $response = $this->getClient()->get($url); $json = $response->json(); $records = $this->getRecordFactory()->createRecordsFromJSONRecordsArray($this->getContentTypeDefinition($contentTypeName), $json['records']); return $records; }