Skip to content

Commit

Permalink
Added support for l10n properties
Browse files Browse the repository at this point in the history
  • Loading branch information
dominiclord committed Dec 5, 2019
1 parent a1b7237 commit b97e838
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions src/Charcoal/Property/EmbedProperty.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,20 @@

namespace Charcoal\Property;

use Charcoal\Embed\Mixin\EmbedRepositoryTrait;
use RuntimeException;

// From Pimple
use Pimple\Container;

// From 'charcoal-translator'
use Charcoal\Translator\Translation;

// From 'charcoal-property'
use Charcoal\Embed\Service\EmbedRepository;
use Charcoal\Property\UrlProperty;
use Pimple\Container;

// From 'charcoal-contrib-embed'
use Charcoal\Embed\Mixin\EmbedRepositoryTrait;
use Charcoal\Embed\Service\EmbedRepository;

/**
* Class EmbedProperty
Expand Down Expand Up @@ -60,10 +67,17 @@ public function save($val)
{
$val = parent::save($val);

$this->embedRepository()->saveEmbedData(
(string)$this->translator()->translation($val),
$this->embedFormat()
);
if ($val instanceof Translation) {
foreach ($val->data() as $lang => $value) {
if (!empty($value)) {
$this->embedRepository()->saveEmbedData($value, $this->embedFormat());
}
}
} else {
if (!empty($val)) {
$this->embedRepository()->saveEmbedData($val, $this->embedFormat());
}
}

return $val;
}
Expand Down

0 comments on commit b97e838

Please sign in to comment.