Skip to content

Commit

Permalink
Translate: Fix null created_by errors by attaching Trackable to i18n
Browse files Browse the repository at this point in the history
  • Loading branch information
rchavik committed Mar 10, 2020
1 parent bd38f5b commit 2e8f9a0
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/Model/Behavior/TranslateBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ public function __construct(Table $table, array $config = [])
return parent::__construct($table, $config);
}

/**
* initialize
*/
public function initialize(array $config)
{
parent::initialize($config);
$this->_translationTable->addBehavior('Croogo/Core.Trackable');
}

/**
* Delete translations
*/
public function deleteTranslation(EntityInterface $entity, string $locale)
{
$runtimeModelAlias = $this->_translationTable->getAlias();
Expand All @@ -32,6 +44,9 @@ public function deleteTranslation(EntityInterface $entity, string $locale)
return $this->_translationTable->deleteAll($deleteCond);
}

/**
* When missing, populate _locale with default value
*/
public function beforeMarshal(Event $event, ArrayObject $data, ArrayObject $options)
{
if (empty($data['_locale'])) {
Expand Down

0 comments on commit 2e8f9a0

Please sign in to comment.