From 94fdb9d2ac0346b08a6d266fff806d4b9ab790d1 Mon Sep 17 00:00:00 2001 From: Bozhidar Hristov Date: Wed, 3 Jan 2018 16:42:00 +0200 Subject: [PATCH] Add missing docs --- README.md | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7ccb599..5af2cdc 100644 --- a/README.md +++ b/README.md @@ -222,7 +222,7 @@ class NewsTranslation implements Translation /** * @param News $translatable */ - public function setTranslatable(News $translatable) + public function setTranslatable(News $translatable = null) { $this->translatable = $translatable; } @@ -341,6 +341,30 @@ doctrine: resolve_target_entities: VM5\EntityTranslationsBundle\Model\Language: Example\Language ``` + +Translatable should have `addTranslation`, `removeTranslation` ( +see by-reference +and +How to Work with Doctrine Associations / Relations +): + +```php + + public function addTranslation(NewsTranslation $translation) + { + if (!$this->translations->contains($translation)) { + $this->translations->add($translation); + $translation->setTranslatable($this); + } + } + + + public function removeTranslation(NewsTranslation $translation) + { + $this->translations->removeElement($translation); + $translation->setTranslatable(null); + } +``` Translation should implements `EditableTranslation` instead of simple `Translation` ```php