Skip to content

Commit

Permalink
Revert "fix #114"
Browse files Browse the repository at this point in the history
This reverts commit 298eae9.
  • Loading branch information
david authored and david committed Apr 7, 2014
1 parent 27ed339 commit bd0a8ae
Showing 1 changed file with 4 additions and 22 deletions.
26 changes: 4 additions & 22 deletions Form/EventListener/TranslationsListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
class TranslationsListener implements EventSubscriberInterface
{
private $translationForm;
private $unusedLocales = array();

/**
*
Expand Down Expand Up @@ -49,22 +48,6 @@ public function preSetData(FormEvent $event)
}
}

/**
*
* @param \Symfony\Component\Form\FormEvent $event
*/
public function preSubmit(FormEvent $event)
{
$data = $event->getData();

foreach ($data as $locale => $translation) {
// Detect and trace unused locale
if (!array_filter($translation)) {
$this->unusedLocales[$locale] = $locale;
}
}
}

/**
*
* @param \Symfony\Component\Form\FormEvent $event
Expand All @@ -74,9 +57,9 @@ public function submit(FormEvent $event)
$data = $event->getData();

foreach ($data as $locale => $translation) {
// Remove unused locale if necessary
if (isset($this->unusedLocales[$locale])) {
unset($data[$locale]);
// Remove useless Translation object
if (!$translation) {
$data->removeElement($translation);

} else {
$translation->setLocale($locale);
Expand All @@ -88,8 +71,7 @@ public static function getSubscribedEvents()
{
return array(
FormEvents::PRE_SET_DATA => 'preSetData',
FormEvents::PRE_SUBMIT => 'preSubmit',
FormEvents::SUBMIT => 'submit',
);
}
}
}

0 comments on commit bd0a8ae

Please sign in to comment.