-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for adding translations
- Loading branch information
Ivan Wolf
committed
Aug 26, 2015
1 parent
4d1e163
commit b746c7b
Showing
2 changed files
with
65 additions
and
9 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
src/Detail/Persistence/Model/Behavior/Translatable/KnpTranslatableTrait.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace Detail\Persistence\Model\Behavior\Translatable; | ||
|
||
use Knp\DoctrineBehaviors\Model as ORMBehaviors; | ||
|
||
trait KnpTranslatableTrait | ||
{ | ||
/** | ||
* @param string $locale | ||
* @return TranslationInterface | ||
*/ | ||
protected function createAndAddTranslation($locale) | ||
{ | ||
$class = self::getTranslationEntityClass(); | ||
/** @var ORMBehaviors\Translatable\Translation $translation */ | ||
$translation = new $class(); | ||
$translation->setLocale($locale); | ||
|
||
$this->addTranslation($translation); | ||
|
||
return $translation; | ||
} | ||
|
||
/** | ||
* @param ORMBehaviors\Translatable\Translation $translation | ||
* @return $this | ||
*/ | ||
abstract public function addTranslation($translation); | ||
|
||
/** | ||
* @return string | ||
*/ | ||
abstract public function getTranslationEntityClass(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters