/** * @param Form $form */ public function processTranslations(Form $form) { $values = $form->getValues(); /** @var $entity TranslatableEntity */ $entity = $this->entity; $columns = $entity->getTranslatableColumns(); foreach ($this->languages as $language) { if (isset($values->translations[$language->id])) { $translation = $values->translations[$language->id]; foreach ($translation as $key => $value) { if (array_key_exists($key, $columns)) { $this->entity->{$key} = $value; } } $this->entity->language = $language; $this->repository->persist($this->entity); } } }
/** * @param Form $form */ public function processValues(Form $form) { $values = $form->getValues(); $properties = $this->entity->getReflection()->getEntityProperties(); $modified = $this->entity->getModifiedRowData(); foreach ($values as $key => $value) { if ($value instanceof FileUpload || $value instanceof \Traversable) { continue; } if (array_key_exists($key, $properties)) { $property = $properties[$key]; if ($property->hasRelationship() === false && $property->isBasicType() && !array_key_exists($key, $modified)) { $this->entity->{$key} = $value; } } } if ($this->entity->isModified()) { $this->repository->persist($this->entity); } }