From cb27229e6cb1598cb06cf8f1dd6594cef2f09a34 Mon Sep 17 00:00:00 2001 From: Mathieu Lemoine Date: Mon, 13 Jun 2016 11:12:04 -0400 Subject: [PATCH] Fix interaction between translations & joined inheritance --- config/orm-services.yml | 1 - src/ORM/Translatable/TranslatableSubscriber.php | 16 +++++++++------- .../DoctrineBehaviors/ORM/TranslatableTest.php | 1 - 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/config/orm-services.yml b/config/orm-services.yml index 07edfb15..c379010c 100755 --- a/config/orm-services.yml +++ b/config/orm-services.yml @@ -38,7 +38,6 @@ services: public: false arguments: - "@knp.doctrine_behaviors.reflection.class_analyzer" - - "%knp.doctrine_behaviors.reflection.is_recursive%" - "@knp.doctrine_behaviors.translatable_subscriber.current_locale_callable" - "@knp.doctrine_behaviors.translatable_subscriber.default_locale_callable" - "%knp.doctrine_behaviors.translatable_subscriber.translatable_trait%" diff --git a/src/ORM/Translatable/TranslatableSubscriber.php b/src/ORM/Translatable/TranslatableSubscriber.php index 8859e863..18a5af12 100644 --- a/src/ORM/Translatable/TranslatableSubscriber.php +++ b/src/ORM/Translatable/TranslatableSubscriber.php @@ -41,11 +41,11 @@ class TranslatableSubscriber extends AbstractSubscriber private $translatableFetchMode; private $translationFetchMode; - public function __construct(ClassAnalyzer $classAnalyzer, $isRecursive, callable $currentLocaleCallable = null, + public function __construct(ClassAnalyzer $classAnalyzer, callable $currentLocaleCallable = null, callable $defaultLocaleCallable = null,$translatableTrait, $translationTrait, $translatableFetchMode, $translationFetchMode) { - parent::__construct($classAnalyzer, $isRecursive); + parent::__construct($classAnalyzer, false); $this->currentLocaleCallable = $currentLocaleCallable; $this->defaultLocaleCallable = $defaultLocaleCallable; @@ -280,22 +280,24 @@ private function hasUniqueTranslationConstraint(ClassMetadata $classMetadata, $n * Checks if entity is translatable * * @param ClassMetadata $classMetadata - * @param bool $isRecursive true to check for parent classes until found * * @return boolean */ - private function isTranslatable(ClassMetadata $classMetadata, $isRecursive = false) + private function isTranslatable(ClassMetadata $classMetadata) { - return $this->getClassAnalyzer()->hasTrait($classMetadata->reflClass, $this->translatableTrait, $this->isRecursive); + return $this->getClassAnalyzer()->hasTrait($classMetadata->reflClass, $this->translatableTrait); } /** - * @param ClassMetadata $classMetadata + * Checks if entity is a translation + * + * @param ClassMetadata $classMetadata + * * @return boolean */ private function isTranslation(ClassMetadata $classMetadata) { - return $this->getClassAnalyzer()->hasTrait($classMetadata->reflClass, $this->translationTrait, $this->isRecursive); + return $this->getClassAnalyzer()->hasTrait($classMetadata->reflClass, $this->translationTrait); } public function postLoad(LifecycleEventArgs $eventArgs) diff --git a/tests/Knp/DoctrineBehaviors/ORM/TranslatableTest.php b/tests/Knp/DoctrineBehaviors/ORM/TranslatableTest.php index 542067ab..59a4a864 100644 --- a/tests/Knp/DoctrineBehaviors/ORM/TranslatableTest.php +++ b/tests/Knp/DoctrineBehaviors/ORM/TranslatableTest.php @@ -26,7 +26,6 @@ protected function getEventManager() $em->addEventSubscriber(new \Knp\DoctrineBehaviors\ORM\Translatable\TranslatableSubscriber( new ClassAnalyzer(), - false, function() { return 'en';