/**
  * Creates record object from (array) decoded JSON record (json_decode($json,true))
  *
  * @param DataTypeDefinition $dataTypeDefinition
  * @param                    $jsonRecord
  * @param string             $viewName
  * @param string             $workspace
  * @param string             $language
  *
  * @return Config|Record
  */
 public function createRecordFromJSON(DataTypeDefinition $dataTypeDefinition, $jsonRecord, $viewName = "default", $workspace = "default", $language = "default")
 {
     if ($dataTypeDefinition instanceof ConfigTypeDefinition) {
         $classname = $this->getRecordClassForConfigType($dataTypeDefinition->getName());
         /** @var Config $record */
         $record = new $classname($dataTypeDefinition, $viewName, $workspace, $language);
     } else {
         $classname = $this->getRecordClassForContentType($dataTypeDefinition->getName());
         /** @var Record $record */
         $record = new $classname($dataTypeDefinition, '', $viewName, $workspace, $language);
         $record->setID($jsonRecord['id']);
     }
     $record = $this->finishRecordCreationFromJSON($record, $jsonRecord);
     return $record;
 }
 public function __construct(DataTypeDefinition $definition, $property, $type)
 {
     $this->dataTypeDefinition = $definition;
     if (!$definition->hasProperty($property)) {
         throw new AnyContentClientException('Unknown sequence property ' . $property . ' for data type ' . $definition->getName());
     }
     $this->type = $type;
 }
 public function getDataTypeName()
 {
     return $this->dataTypeDefinition->getName();
 }
 public function setCurrentDataType(DataTypeDefinition $dataTypeDefinition)
 {
     $this->dataTypeDefinition = $dataTypeDefinition;
     $contentType = $dataTypeDefinition->getTitle();
     if (!$contentType) {
         $contentType = $dataTypeDefinition->getName();
     }
     // check workspaces
     $workspaces = $dataTypeDefinition->getWorkspaces();
     if (!array_key_exists($this->getCurrentWorkspace(), $workspaces)) {
         reset($workspaces);
         list($key, $workspace) = each($workspaces);
         $this->setCurrentWorkspace($key);
         $this->addInfoMessage('Switching to workspace ' . $workspace . ' (' . $key . ') for content type ' . $contentType . '.');
     }
     if ($dataTypeDefinition->hasLanguages()) {
         $languages = $dataTypeDefinition->getLanguages();
     } else {
         $languages = array('default' => 'None');
     }
     if (!array_key_exists($this->getCurrentLanguage(), $languages)) {
         reset($languages);
         list($key, $language) = each($languages);
         $this->setCurrentLanguage($key);
         $this->addInfoMessage('Switching to language ' . $language . ' (' . $key . ') for content type ' . $contentType . '.');
     }
     if (!$dataTypeDefinition->isTimeShiftable() and $this->getCurrentTimeShift() != 0) {
         $this->resetTimeShift();
     }
 }