Skip to content

Commit

Permalink
Merge pull request #317 from lemoinem/fix/translatable/joined-inherit…
Browse files Browse the repository at this point in the history
…ance

Fix interaction between translations & joined inheritance
  • Loading branch information
docteurklein authored Sep 29, 2016
2 parents 76189c2 + cb27229 commit 9cfefd5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
1 change: 0 additions & 1 deletion config/orm-services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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%"
Expand Down
16 changes: 9 additions & 7 deletions src/ORM/Translatable/TranslatableSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion tests/Knp/DoctrineBehaviors/ORM/TranslatableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ protected function getEventManager()

$em->addEventSubscriber(new \Knp\DoctrineBehaviors\ORM\Translatable\TranslatableSubscriber(
new ClassAnalyzer(),
false,
function()
{
return 'en';
Expand Down

0 comments on commit 9cfefd5

Please sign in to comment.