/**
  * Finds the field with id $fieldId in $content.
  *
  * @param int $fieldId
  * @param Content $content
  *
  * @return Field
  */
 protected function findFieldInContent($fieldId, Content $content)
 {
     foreach ($content->getFields() as $field) {
         if ($field->id == $fieldId) {
             return $field;
         }
     }
     throw new InvalidArgumentException("Field with id {$fieldId} not found in Content with id {$content->id}");
 }
 /**
  * Maps Repository Content to the Site Content.
  *
  * @param \eZ\Publish\API\Repository\Values\Content\Content $content
  * @param string $languageCode
  *
  * @return \Netgen\EzPlatformSiteApi\Core\Site\Values\Content
  */
 public function mapContent(APIContent $content, $languageCode)
 {
     $contentType = $this->contentTypeService->loadContentType($content->contentInfo->contentTypeId);
     $fields = $content->getFieldsByLanguage($languageCode);
     $fieldsData = [];
     foreach ($fields as $field) {
         $fieldsData[] = $this->mapFieldData($field, $contentType);
     }
     return new Content(['_fields_data' => $fieldsData, 'contentInfo' => $this->mapContentInfo($content->versionInfo, $languageCode, $contentType), 'innerContent' => $content]);
 }
Exemplo n.º 3
0
 public function castContent(Content $content, array $a, Stub $stub, $isNested, $filter = 0)
 {
     $info = $content->contentInfo;
     $a = [Caster::PREFIX_VIRTUAL . 'id' => $info->id, Caster::PREFIX_VIRTUAL . 'name' => $info->name] + $a;
     if (!$filter & Caster::EXCLUDE_VERBOSE) {
         $groupedFields = [];
         foreach ($content->getFields() as $field) {
             $groupedFields[$field->languageCode][$field->fieldDefIdentifier] = $field->value;
         }
         $a += [Caster::PREFIX_VIRTUAL . 'names' => $content->versionInfo->getNames(), Caster::PREFIX_VIRTUAL . 'contentInfo' => $info, Caster::PREFIX_VIRTUAL . 'fields' => $groupedFields];
     }
     return $a;
 }
 /**
  * Returns Field object in the appropriate language for a given content.
  * By default, this method will return the field in current language if translation is present. If not, main language will be used.
  * If $forcedLanguage is provided, will return the field in this language, if translation is present.
  *
  * @param \eZ\Publish\API\Repository\Values\Content\Content $content
  * @param string $fieldDefIdentifier Field definition identifier.
  * @param string $forcedLanguage Locale we want the field translation in (e.g. "fre-FR"). Null by default (takes current locale)
  *
  * @return \eZ\Publish\API\Repository\Values\Content\Field|null
  */
 public function getTranslatedField(Content $content, $fieldDefIdentifier, $forcedLanguage = null)
 {
     if ($forcedLanguage !== null) {
         $languages = array($forcedLanguage);
     } else {
         $languages = $this->configResolver->getParameter('languages');
     }
     // Always add null as last entry so that we can use it pass it as languageCode $content->getField(),
     // forcing to use the main language if all others fail.
     $languages[] = null;
     // Loop over prioritized languages to get the appropriate translated field.
     foreach ($languages as $lang) {
         $field = $content->getField($fieldDefIdentifier, $lang);
         if ($field instanceof Field) {
             return $field;
         }
     }
 }
 /**
  * Test for the updateContentMetadata() method.
  *
  * @param \eZ\Publish\API\Repository\Values\Content\Content $content
  *
  * @return void
  * @see \eZ\Publish\API\Repository\ContentService::updateContentMetadata()
  * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testUpdateContentMetadata
  */
 public function testUpdateContentMetadataNotUpdatesContentVersion($content)
 {
     $this->assertEquals(1, $content->getVersionInfo()->versionNo);
 }
 /**
  * Asserts that $copiedContent is valid copy of $originalContent
  *
  * @param \eZ\Publish\API\Repository\Values\Content\Content $originalContent
  * @param \eZ\Publish\API\Repository\Values\Content\Content $copiedContent
  */
 protected function assertCopyContentValues(APIContent $originalContent, APIContent $copiedContent)
 {
     $this->assertNotEquals($originalContent->id, $copiedContent->id, "Id of content copy is equal to id od original content");
     $this->assertSameClassPropertiesCorrect(array("contentTypeId", "sectionId", "published", "ownerId", "alwaysAvailable", "mainLanguageCode"), $originalContent->contentInfo, $copiedContent->contentInfo);
     $this->assertNotEquals($originalContent->contentInfo->id, $copiedContent->contentInfo->id);
     $this->assertNotEquals($originalContent->contentInfo->remoteId, $copiedContent->contentInfo->remoteId);
     $this->assertSameClassPropertiesCorrect(array("versionNo", "names", "creatorId", "initialLanguageCode", "languageCodes"), $originalContent->versionInfo, $copiedContent->versionInfo);
     $this->assertNotEquals($originalContent->versionInfo->id, $copiedContent->versionInfo->id);
     $originalFields = $originalContent->getFields();
     $copiedFields = $copiedContent->getFields();
     $this->assertCount(count($originalFields), $copiedFields, "Count of fields copied does not match the count of original fields");
     foreach ($originalFields as $fieldIndex => $originalField) {
         $this->assertSameClassPropertiesCorrect(array("fieldDefIdentifier", "value", "languageCode"), $originalField, $copiedFields[$fieldIndex]);
         $this->assertNotEquals($originalField->id, $copiedFields[$fieldIndex]->id);
     }
 }
 /**
  * Method for parsing ezobjectrelation field.
  * For now related fields refer to images.
  *
  * @param \eZ\Publish\API\Repository\Values\Content\Field $field
  * @param \eZ\Publish\API\Repository\Values\Content\Content $content
  * @param string $language
  * @param string $imageFieldIdentifier
  *
  * @return string
  */
 public function ezobjectrelation(Field $field, Content $content, $language, $imageFieldIdentifier)
 {
     $fields = $content->getFieldsByLanguage($language);
     foreach ($fields as $type => $field) {
         if ($type == $imageFieldIdentifier) {
             return $this->ezimage($field, $content);
         }
     }
     return '';
 }
Exemplo n.º 8
0
 /**
  * Asserts that $copiedContent is valid copy of $originalContent.
  *
  * @param \eZ\Publish\API\Repository\Values\Content\Content $originalContent
  * @param \eZ\Publish\API\Repository\Values\Content\Content $copiedContent
  */
 protected function assertCopyContentValues(APIContent $originalContent, APIContent $copiedContent)
 {
     $this->assertNotEquals($originalContent->id, $copiedContent->id, 'Id of content copy is equal to id od original content');
     $this->assertSameClassPropertiesCorrect(array('contentTypeId', 'sectionId', 'published', 'ownerId', 'alwaysAvailable', 'mainLanguageCode'), $originalContent->contentInfo, $copiedContent->contentInfo);
     $this->assertNotEquals($originalContent->contentInfo->id, $copiedContent->contentInfo->id);
     $this->assertNotEquals($originalContent->contentInfo->remoteId, $copiedContent->contentInfo->remoteId);
     $this->assertSameClassPropertiesCorrect(array('versionNo', 'names', 'creatorId', 'initialLanguageCode', 'languageCodes'), $originalContent->versionInfo, $copiedContent->versionInfo);
     $this->assertNotEquals($originalContent->versionInfo->id, $copiedContent->versionInfo->id);
     $originalFields = $originalContent->getFields();
     $copiedFields = $copiedContent->getFields();
     $this->assertCount(count($originalFields), $copiedFields, 'Count of fields copied does not match the count of original fields');
     foreach ($originalFields as $fieldIndex => $originalField) {
         $this->assertSameClassPropertiesCorrect(array('fieldDefIdentifier', 'value', 'languageCode'), $originalField, $copiedFields[$fieldIndex]);
         $this->assertNotEquals($originalField->id, $copiedFields[$fieldIndex]->id);
     }
 }
 /**
  * Returns the field type identifier for $field
  *
  * @param \eZ\Publish\API\Repository\Values\Content\Content $content
  * @param \eZ\Publish\API\Repository\Values\Content\Field $field
  *
  * @return string
  */
 protected function getFieldTypeIdentifier(Content $content, Field $field)
 {
     $contentInfo = $content->getVersionInfo()->getContentInfo();
     $key = $contentInfo->contentTypeId . '  ' . $field->fieldDefIdentifier;
     if (!isset($this->fieldTypeIdentifiers[$key])) {
         $contentType = $this->repository->getContentTypeService()->loadContentType($contentInfo->contentTypeId);
         $this->fieldTypeIdentifiers[$key] = $contentType->getFieldDefinition($field->fieldDefIdentifier)->fieldTypeIdentifier;
     }
     return $this->fieldTypeIdentifiers[$key];
 }
Exemplo n.º 10
0
 public function __get($property)
 {
     switch ($property) {
         case 'contentInfo':
             return $this->getContentInfo();
         case 'versionInfo':
             return $this->getVersionInfo();
     }
     return parent::__get($property);
 }
Exemplo n.º 11
0
 /**
  * Renders $content by selecting the right template.
  * $content will be injected in the selected template.
  *
  * @param \eZ\Publish\API\Repository\Values\Content\Content $content
  * @param string $viewType Variation of display for your content. Default is 'full'.
  * @param array $parameters Parameters to pass to the template called to
  *        render the view. By default, it's empty. 'content' entry is
  *        reserved for the Content that is rendered.
  * @throws \RuntimeException
  *
  * @return string
  */
 public function renderContent(Content $content, $viewType = ViewManagerInterface::VIEW_TYPE_FULL, $parameters = array())
 {
     $contentInfo = $content->getVersionInfo()->getContentInfo();
     foreach ($this->getAllContentViewProviders() as $viewProvider) {
         $view = $viewProvider->getView($contentInfo, $viewType);
         if ($view instanceof ContentViewInterface) {
             $parameters['content'] = $content;
             return $this->renderContentView($view, $parameters);
         }
     }
     throw new RuntimeException("Unable to find a template for #{$contentInfo->id}");
 }
 /**
  * Returns author of the content.
  *
  * @param \eZ\Publish\API\Repository\Values\Content\Content $contentValue
  * @param \eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType
  *
  * @return string
  */
 private function getAuthor(Content $contentValue, ContentType $contentType)
 {
     $author = $contentValue->getFieldValue($this->value->getConfiguredFieldIdentifier('author', $contentType));
     if (null === $author) {
         $ownerId = empty($contentValue->contentInfo->ownerId) ? $this->defaultAuthorId : $contentValue->contentInfo->ownerId;
         $userContentInfo = $this->contentService->loadContentInfo($ownerId);
         $author = $userContentInfo->name;
     }
     return (string) $author;
 }
Exemplo n.º 13
0
 /**
  * Checks if content has image relation field, returns its ID if true.
  *
  * @param \eZ\Publish\API\Repository\Values\Content\Content $content
  * @param string $field
  * @param string $language
  *
  * @return int|null
  */
 private function getRelation(Content $content, $field, $language)
 {
     $fieldDefinitions = $this->getFieldDefinitionList();
     $fieldNames = array_flip($fieldDefinitions);
     $isRelation = in_array('ezobjectrelation', $fieldDefinitions) && $field == $fieldNames['ezobjectrelation'];
     if ($isRelation && $field == $fieldNames['ezobjectrelation']) {
         $fieldValue = $content->getFieldValue($fieldNames['ezobjectrelation'], $language);
         if (isset($fieldValue->destinationContentId)) {
             return $fieldValue->destinationContentId;
         }
     }
     return null;
 }
Exemplo n.º 14
0
 /**
  * Returns preview for $content (versionNo to display is held in $content->versionInfo).
  *
  * @param \eZ\Publish\API\Repository\Values\Content\Content $content
  * @param array $params Hash of arbitrary parameters to pass to final view
  * @param \eZ\Publish\Core\MVC\Legacy\Templating\LegacyHelper $legacyHelper
  *
  * @return string
  */
 public function renderPreview(APIContent $content, array $params, LegacyHelper $legacyHelper)
 {
     /** @var \eZ\Publish\Core\MVC\Symfony\SiteAccess $siteAccess */
     $siteAccess = $this->getCurrentRequest()->attributes->get('siteaccess');
     $moduleResult = array();
     // Filling up moduleResult
     $result = $this->getLegacyKernel()->runCallback(function () use($content, $params, $siteAccess, &$moduleResult) {
         $contentViewModule = eZModule::findModule('content');
         $moduleResult = $contentViewModule->run('versionview', array($content->contentInfo->id, $content->getVersionInfo()->versionNo, $content->getVersionInfo()->languageCodes[0]), false, array('site_access' => $siteAccess->name) + $params);
         return ezpEvent::getInstance()->filter('response/output', $moduleResult['content']);
     }, false);
     $legacyHelper->loadDataFromModuleResult($moduleResult);
     return $result;
 }
 /**
  * reimp this function!
  *
  * Get and builds a form schema / entity from an content object with fields
  *
  * @param string $contentType
  * @param string $languageCode
  * @param \eZ\Publish\API\Repository\Values\Content\Content $content
  * @param bool $isCollector
  *
  * @return array $formSchemaArr,$formValueArr
  */
 public function getFormSchemaFromContentObjectFields($contentType, $languageCode = 'eng-GB', $content = false, $isCollector = false)
 {
     $formValueArr = array();
     $formSchemaArr = array();
     $contentTypeConfig = false;
     if (isset($this->config['frontendediting_config']['types'][$contentType->identifier])) {
         $contentTypeConfig = $this->config['frontendediting_config']['types'][$contentType->identifier];
     }
     foreach ($contentType->getFieldDefinitions() as $field) {
         if ($isCollector !== true || $isCollector === true && $field->isInfoCollector) {
             if (!isset($contentTypeConfig['fields']) || in_array($field->identifier, $contentTypeConfig['fields'])) {
                 $fieldArr = array();
                 $fieldArr1 = false;
                 $fieldArr2 = false;
                 //                $fieldArr['position'] = $field->position;
                 // TODO check if the name for a language code is set otherwise fall back
                 // maybe use ez
                 //var_dump( $field->names );
                 $fieldArr['label'] = $field->names[$languageCode];
                 $fieldArr['required'] = $field->isRequired;
                 $fieldArr['choices'] = false;
                 // map ez types to symfony types
                 // http://symfony.com/doc/current/reference/forms/types.html
                 // ToDo: to many
                 switch ($field->fieldTypeIdentifier) {
                     case 'ezstring':
                         $formFieldIdentifier = 'ezstring' . FormHandlerService::separator . $field->identifier;
                         $fieldArr['type'] = 'text';
                         $fieldArr['value'] = $field->defaultValue->text;
                         break;
                     case 'eztext':
                         $formFieldIdentifier = 'eztext' . FormHandlerService::separator . $field->identifier;
                         $fieldArr['type'] = 'textarea';
                         $fieldArr['value'] = $field->defaultValue->text;
                         break;
                     case 'ezxmltext':
                         $formFieldIdentifier = 'ezxmltext' . FormHandlerService::separator . $field->identifier;
                         $fieldArr['type'] = 'textarea';
                         // ToDo
                         //                            $fieldArr['value'] = $this->ezXmltextToHtml( $content, $field );
                         $fieldArr['value'] = '';
                         break;
                     case 'ezemail':
                         $formFieldIdentifier = 'ezemail' . FormHandlerService::separator . $field->identifier;
                         $fieldArr['type'] = 'email';
                         $fieldArr['value'] = $field->defaultValue->email;
                         break;
                     case 'ezboolean':
                         $formFieldIdentifier = 'ezxmltext' . FormHandlerService::separator . $field->identifier;
                         $fieldArr['type'] = 'checkbox';
                         $fieldArr['value'] = $field->defaultValue->bool;
                         break;
                     case 'ezuser':
                         // ToDo: many
                         $formFieldIdentifier = 'ezuser' . FormHandlerService::separator . $field->identifier . FormHandlerService::separator . 'login';
                         $fieldArr['type'] = 'text';
                         $fieldArr['label'] = 'cjw_publishtools.formbuilder.user.login';
                         $fieldArr['value'] = '';
                         $fieldArr1 = array();
                         $fieldArr1['type'] = 'email';
                         $fieldArr1['label'] = 'cjw_publishtools.formbuilder.user.email';
                         $fieldArr1['required'] = true;
                         $formFieldIdentifier1 = 'ezuser' . FormHandlerService::separator . $field->identifier . FormHandlerService::separator . 'email';
                         $fieldArr1['value'] = '';
                         $fieldArr1['choices'] = false;
                         $fieldArr2 = array();
                         $fieldArr2['type'] = 'password';
                         $fieldArr2['label'] = 'cjw_publishtools.formbuilder.user.password';
                         $fieldArr2['required'] = true;
                         $formFieldIdentifier2 = 'ezuser' . FormHandlerService::separator . $field->identifier . FormHandlerService::separator . 'password';
                         $fieldArr2['value'] = '';
                         $fieldArr2['choices'] = false;
                         break;
                         // ToDo: multiple / single, select / radio / checkbox, etc.
                     // ToDo: multiple / single, select / radio / checkbox, etc.
                     case 'ezselection':
                         $formFieldIdentifier = 'ezselection' . FormHandlerService::separator . $field->identifier;
                         $fieldArr['type'] = 'choice';
                         $fieldArr['choices'] = array();
                         // Translate choices, which aren't translatable in eZ BackEnd
                         foreach ($field->fieldSettings['options'] as $fieldChoiceKey => $fieldChoice) {
                             $fieldArr['choices'][$fieldChoiceKey] = $this->container->get('translator')->trans($fieldChoice);
                         }
                         // http://stackoverflow.com/questions/17314996/symfony2-array-to-string-conversion-error
                         if ($field->fieldSettings['isMultiple']) {
                             $fieldArr['multiple'] = true;
                             $fieldArr['value'] = $field->defaultValue->selection;
                         } else {
                             $fieldArr['multiple'] = false;
                             $fieldArr['value'] = false;
                             if (isset($field->defaultValue->selection['0'])) {
                                 $fieldArr['value'] = $field->defaultValue->selection['0'];
                             }
                         }
                         break;
                     default:
                         $formFieldIdentifier = 'default' . FormHandlerService::separator . $field->identifier;
                         $fieldArr['type'] = 'text';
                         $fieldArr['value'] = '';
                 }
                 // build / set entity array dynamicaly from fieldtype
                 if ($content) {
                     $formFieldIdentifierArr = explode(':', $formFieldIdentifier);
                     switch ($formFieldIdentifierArr['0']) {
                         case 'ezuser':
                             $userValue = $content->getFieldValue($field->identifier);
                             $fieldArr['value'] = $userValue->login;
                             $fieldArr1['value'] = $userValue->email;
                             break;
                         default:
                             switch ($fieldArr['type']) {
                                 case 'choice':
                                     // http://stackoverflow.com/questions/17314996/symfony2-array-to-string-conversion-error
                                     if ($fieldArr['multiple']) {
                                         $fieldArr['value'] = $content->getFieldValue($field->identifier)->selection;
                                     } else {
                                         $fieldArr['value'] = $content->getFieldValue($field->identifier)->selection['0'];
                                     }
                                     break;
                                 default:
                                     if (isset($content->getFieldValue($field->identifier)->text)) {
                                         $fieldArr['value'] = $content->getFieldValue($field->identifier)->text;
                                     }
                             }
                     }
                 }
                 $formValueArr[$formFieldIdentifier] = $fieldArr['value'];
                 $formSchemaArr[$formFieldIdentifier] = $fieldArr;
                 if ($fieldArr1 !== false) {
                     $formValueArr[$formFieldIdentifier1] = $fieldArr1['value'];
                     $formSchemaArr[$formFieldIdentifier1] = $fieldArr1;
                 }
                 if ($fieldArr2 !== false) {
                     $formValueArr[$formFieldIdentifier2] = $fieldArr2['value'];
                     $formSchemaArr[$formFieldIdentifier2] = $fieldArr2;
                 }
             }
         }
     }
     return array($formSchemaArr, $formValueArr);
 }
Exemplo n.º 16
0
 public function getFirstFilledImageFieldIdentifier(Content $content)
 {
     foreach ($content->getFieldsByLanguage() as $field) {
         $fieldTypeIdentifier = $this->fieldHelper->getFieldDefinition($content->contentInfo, $field->fieldDefIdentifier)->fieldTypeIdentifier;
         if ($fieldTypeIdentifier !== 'ezimage') {
             continue;
         }
         if ($this->fieldHelper->isFieldEmpty($content, $field->fieldDefIdentifier)) {
             continue;
         }
         return $field->fieldDefIdentifier;
     }
     return null;
 }
Exemplo n.º 17
0
 /**
  * This method returns the field for a given field definition identifier and language
  *
  * If not set the initialLanguage of the content version is used.
  *
  * @param string $fieldDefIdentifier
  * @param string|null $languageCode
  *
  * @return \eZ\Publish\API\Repository\Values\Content\Field|null A {@link Field} or null if nothing is found
  */
 public function getField($fieldDefIdentifier, $languageCode = null)
 {
     return $this->content->getField($fieldDefIdentifier, $languageCode);
 }
 /**
  * Returns Field object in the appropriate language for a given content.
  * By default, this method will return the field in current language if translation is present. If not, main language will be used.
  * If $forcedLanguage is provided, will return the field in this language, if translation is present.
  *
  * @param \eZ\Publish\API\Repository\Values\Content\Content $content
  * @param string $fieldDefIdentifier Field definition identifier.
  * @param string $forcedLanguage Locale we want the field translation in (e.g. "fre-FR"). Null by default (takes current locale)
  *
  * @return \eZ\Publish\API\Repository\Values\Content\Field|null
  */
 public function getTranslatedField(Content $content, $fieldDefIdentifier, $forcedLanguage = null)
 {
     // Loop over prioritized languages to get the appropriate translated field.
     foreach ($this->getLanguages($forcedLanguage) as $lang) {
         $field = $content->getField($fieldDefIdentifier, $lang);
         if ($field instanceof Field) {
             return $field;
         }
     }
 }
 protected function assertFieldIds(Content $content1, Content $content2)
 {
     $fields1 = $this->mapFields($content1->getFields());
     $fields2 = $this->mapFields($content2->getFields());
     foreach ($fields1 as $fieldDefinitionIdentifier => $languageFieldIds) {
         foreach ($languageFieldIds as $languageCode => $fieldId) {
             $this->assertEquals($fields2[$fieldDefinitionIdentifier][$languageCode], $fieldId);
         }
     }
 }
 /**
  * @depends testPublishContent
  */
 public function testPublishedName(Content $content)
 {
     $this->assertEquals($content->getFieldValue('name') . ' ' . $this->getFieldName(), $content->contentInfo->name);
 }
Exemplo n.º 21
0
 /**
  * This method returns the fields for a given language and non translatable fields
  *
  * If note set the initialLanguage of the content version is used.
  *
  * @param string $languageCode
  *
  * @return \eZ\Publish\API\Repository\Values\Content\Field[] With field identifier as keys
  */
 public function getFieldsByLanguage($languageCode = null)
 {
     return $this->content->getFieldsByLanguage($languageCode);
 }
Exemplo n.º 22
0
 /**
  * Magic isset for signaling existence of convenience properties
  *
  * @param string $property
  *
  * @return boolean
  */
 public function __isset($property)
 {
     if ($property === 'id') {
         return true;
     }
     if ($property === 'contentInfo') {
         return true;
     }
     return parent::__isset($property);
 }
Exemplo n.º 23
0
 /**
  * Builds the domain UserGroup object from provided Content object
  *
  * @param \eZ\Publish\API\Repository\Values\Content\Content $content
  *
  * @return \eZ\Publish\API\Repository\Values\User\UserGroup
  */
 protected function buildDomainUserGroupObject(APIContent $content)
 {
     $locationService = $this->repository->getLocationService();
     $subGroupCount = 0;
     if ($content->getVersionInfo()->getContentInfo()->mainLocationId !== null) {
         $mainLocation = $locationService->loadLocation($content->getVersionInfo()->getContentInfo()->mainLocationId);
         $parentLocation = $locationService->loadLocation($mainLocation->parentLocationId);
         $subGroups = $this->searchSubGroups($mainLocation->id, null, Location::SORT_ORDER_ASC, 0, 0);
         $subGroupCount = $subGroups->totalCount;
     }
     return new UserGroup(array('content' => $content, 'parentId' => isset($parentLocation) ? $parentLocation->contentId : null, 'subGroupCount' => $subGroupCount));
 }
 /**
  * Copies a content object.
  *
  * @param \eZ\Publish\API\Repository\Values\Content\Content $content
  * @param string[] $overwrites
  *
  * @return Values\Content\ContentStub
  */
 private function copyContentObject(Content $content, array $overwrites = array())
 {
     $names = array('id', 'fields', 'contentTypeId', 'versionNo', 'repository');
     $values = array();
     foreach ($names as $name) {
         if (array_key_exists($name, $overwrites)) {
             $values[$name] = $overwrites[$name];
         } else {
             $values[$name] = $content->{$name};
         }
     }
     $newContent = new ContentStub($values);
     // copy relations
     $relations = $this->loadRelations($content->getVersionInfo());
     foreach ($relations as $relation) {
         $this->addRelation($newContent->getVersionInfo(), $relation->getDestinationContentInfo());
     }
     return $newContent;
 }