Skip to content

Commit

Permalink
Merge pull request doctrine#602 from dantleech/translated_props
Browse files Browse the repository at this point in the history
Fixed translated property name mapping
  • Loading branch information
dbu committed Mar 4, 2015
2 parents 8210438 + 96e6ddc commit 4e470ba
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
Binary file removed lib/Doctrine/ODM/PHPCR/.UnitOfWork.php.swl
Binary file not shown.
4 changes: 2 additions & 2 deletions lib/Doctrine/ODM/PHPCR/Mapping/ClassMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -1379,8 +1379,8 @@ public function mapField(array $mapping, ClassMetadata $inherited = null)
$mapping = $this->validateAndCompleteFieldMapping($mapping, $inherited);

// Add the field to the list of translatable fields
if (!empty($mapping['translated']) && !in_array($mapping['property'], $this->translatableFields)) {
$this->translatableFields[] = $mapping['property'];
if (!empty($mapping['translated']) && !in_array($mapping['fieldName'], $this->translatableFields)) {
$this->translatableFields[] = $mapping['fieldName'];
}

if (!$parentMapping) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ public function saveTranslation(array $data, NodeInterface $node, ClassMetadata
// no need to validate non-nullable condition, the UoW does that for all fields
$nullFields = array();
foreach ($data as $field => $propValue) {
$propName = $this->getTranslatedPropertyName($locale, $field);
$mapping = $metadata->mappings[$field];
$propName = $this->getTranslatedPropertyName($locale, $mapping['property']);

if ($mapping['multivalue'] && $propValue) {
$propValue = (array) $propValue;
Expand Down
3 changes: 3 additions & 0 deletions tests/Doctrine/Tests/Models/Translation/Article.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ class Article
/** @PHPCRODM\String(translated=true, nullable=true) */
public $nullable;

/** @PHPCRODM\String(translated=true, nullable=true, property="custom-property-name") */
public $customPropertyName;

/** @PHPCRODM\String(translated=true, assoc="", nullable=true)*/
public $assoc;

Expand Down

0 comments on commit 4e470ba

Please sign in to comment.