Skip to content

Commit

Permalink
Added changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-marcel committed Mar 8, 2016
1 parent 00a18f0 commit cdbc2d6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
14 changes: 7 additions & 7 deletions Form/EventListener/TranslationsListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function __construct(TranslationForm $translationForm)
public function preSetData(FormEvent $event)
{
$form = $event->getForm();

$translatableClass = $form->getParent()->getConfig()->getDataClass();
$translationClass = $this->getTranslationClass($translatableClass);

Expand All @@ -54,7 +54,7 @@ public function preSetData(FormEvent $event)
}
}
}

/**
*
* @param \Symfony\Component\Form\FormEvent $event
Expand All @@ -67,7 +67,7 @@ public function submit(FormEvent $event)
// Remove useless Translation object
if (!$translation) {
$data->removeElement($translation);

} else {
$translation->setLocale($locale);
}
Expand All @@ -81,7 +81,7 @@ public static function getSubscribedEvents()
FormEvents::SUBMIT => 'submit',
);
}

/**
*
* @param string $translatableClass
Expand All @@ -91,12 +91,12 @@ private function getTranslationClass($translatableClass)
// Knp
if (method_exists($translatableClass, "getTranslationEntityClass")) {
return $translatableClass::getTranslationEntityClass();
// Gedmo

// Gedmo
} elseif (method_exists($translatableClass, "getTranslationClass")) {
return $translatableClass::getTranslationClass();
}

return $translatableClass .'Translation';
}
}
4 changes: 1 addition & 3 deletions Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@
<tag name="form.type" alias="ambta_translationsLocalesSelector" />
</service>
<service id="ambta_translation_form.default.type.translatedEntity" class="%ambta_translation_form.default.type.translatedEntity.class%">
<call method="setRequest">
<argument type="service" id="request" on-invalid="null" strict="false" />
</call>
<argument type="service" id="request_stack" />
<tag name="form.type" alias="ambta_translatedEntity" />
</service>
</services>
Expand Down

0 comments on commit cdbc2d6

Please sign in to comment.