Skip to content

Commit b97e838

Browse files
committed
Added support for l10n properties
1 parent a1b7237 commit b97e838

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

src/Charcoal/Property/EmbedProperty.php

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,20 @@
22

33
namespace Charcoal\Property;
44

5-
use Charcoal\Embed\Mixin\EmbedRepositoryTrait;
65
use RuntimeException;
76

7+
// From Pimple
8+
use Pimple\Container;
9+
10+
// From 'charcoal-translator'
11+
use Charcoal\Translator\Translation;
12+
813
// From 'charcoal-property'
9-
use Charcoal\Embed\Service\EmbedRepository;
1014
use Charcoal\Property\UrlProperty;
11-
use Pimple\Container;
15+
16+
// From 'charcoal-contrib-embed'
17+
use Charcoal\Embed\Mixin\EmbedRepositoryTrait;
18+
use Charcoal\Embed\Service\EmbedRepository;
1219

1320
/**
1421
* Class EmbedProperty
@@ -60,10 +67,17 @@ public function save($val)
6067
{
6168
$val = parent::save($val);
6269

63-
$this->embedRepository()->saveEmbedData(
64-
(string)$this->translator()->translation($val),
65-
$this->embedFormat()
66-
);
70+
if ($val instanceof Translation) {
71+
foreach ($val->data() as $lang => $value) {
72+
if (!empty($value)) {
73+
$this->embedRepository()->saveEmbedData($value, $this->embedFormat());
74+
}
75+
}
76+
} else {
77+
if (!empty($val)) {
78+
$this->embedRepository()->saveEmbedData($val, $this->embedFormat());
79+
}
80+
}
6781

6882
return $val;
6983
}

0 commit comments

Comments
 (0)