Skip to content

Commit 4e470ba

Browse files
committed
Merge pull request #602 from dantleech/translated_props
Fixed translated property name mapping
2 parents 8210438 + 96e6ddc commit 4e470ba

File tree

4 files changed

+6
-3
lines changed

4 files changed

+6
-3
lines changed
-188 KB
Binary file not shown.

lib/Doctrine/ODM/PHPCR/Mapping/ClassMetadata.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1379,8 +1379,8 @@ public function mapField(array $mapping, ClassMetadata $inherited = null)
13791379
$mapping = $this->validateAndCompleteFieldMapping($mapping, $inherited);
13801380

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

13861386
if (!$parentMapping) {

lib/Doctrine/ODM/PHPCR/Translation/TranslationStrategy/AttributeTranslationStrategy.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ public function saveTranslation(array $data, NodeInterface $node, ClassMetadata
4848
// no need to validate non-nullable condition, the UoW does that for all fields
4949
$nullFields = array();
5050
foreach ($data as $field => $propValue) {
51-
$propName = $this->getTranslatedPropertyName($locale, $field);
5251
$mapping = $metadata->mappings[$field];
52+
$propName = $this->getTranslatedPropertyName($locale, $mapping['property']);
5353

5454
if ($mapping['multivalue'] && $propValue) {
5555
$propValue = (array) $propValue;

tests/Doctrine/Tests/Models/Translation/Article.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ class Article
5454
/** @PHPCRODM\String(translated=true, nullable=true) */
5555
public $nullable;
5656

57+
/** @PHPCRODM\String(translated=true, nullable=true, property="custom-property-name") */
58+
public $customPropertyName;
59+
5760
/** @PHPCRODM\String(translated=true, assoc="", nullable=true)*/
5861
public $assoc;
5962

0 commit comments

Comments
 (0)