Controller/FormController.php
private function getApiEntity(Form $entity, $locale)
    {
        // Translation
        $translation = $entity->getTranslation($locale);

        $translations = [];

        if ($translation) {
            $receivers = [];

            foreach ($translation->getReceivers() as $receiver) {
                $receivers[] = [
                    'id' => $receiver->getId(),
                    'name' => $receiver->getName(),
                    'email' => $receiver->getEmail(),
                    'type' => $receiver->getType(),
                ];
            }

            $translations = [
                'title' => $translation->getTitle(),
                'fromEmail' => $translation->getFromEmail(),
                'fromName' => $translation->getFromName(),
                'toEmail' => $translation->getToEmail(),
                'toName' => $translation->getToName(),
                'subject' => $translation->getSubject(),
                'mailText' => $translation->getMailText(),
                'submitLabel' => $translation->getSubmitLabel(),
                'successText' => $translation->getSuccessText(),
                'sendAttachments' => $translation->getSendAttachments(),
                'deactivateNotifyMails' => $translation->getDeactivateNotifyMails(),
                'deactivateCustomerMails' => $translation->getDeactivateCustomerMails(),
                'receivers' => $receivers,
                'replyTo' => $translation->getReplyTo(),
            ];
        }

        // Fields
        $fields = [];

        foreach ($entity->getFields() as $field) {
            $fieldTranslation = $field->getTranslation($locale);

            $fieldData = [
                'id' => $field->getId(),
                'type' => $field->getType(),
                'key' => $field->getKey(),
                'required' => $field->getRequired(),
                'order' => $field->getOrder(),
                'width' => $field->getWidth(),
            ];

            if ($fieldTranslation) {
                $fieldData['title'] = $fieldTranslation->getTitle();
                $fieldData['placeholder'] = $fieldTranslation->getPlaceholder();
                $fieldData['defaultValue'] = $fieldTranslation->getDefaultValue();
                $fieldData['shortTitle'] = $fieldTranslation->getShortTitle();

                foreach ($fieldTranslation->getOptions() as $key => $option) {
                    $fieldData['options[' . $key . ']'] = $option;
                }
            }

            $fields[] = $fieldData;
        }

        // Api Entity
        return array_merge(
            [
                'id' => $entity->getId(),
                'locale' => $locale,
                'fields' => $fields,
            ],
            $translations
        );
    }
private function getApiEntity(Form $entity, $locale)
    {
        // Translation
        $translation = $entity->getTranslation($locale);

        $translations = [];

        if ($translation) {
            $receivers = [];

            foreach ($translation->getReceivers() as $receiver) {
                $receivers[] = [
                    'id' => $receiver->getId(),
                    'name' => $receiver->getName(),
                    'email' => $receiver->getEmail(),
                    'type' => $receiver->getType(),
                ];
            }

            $translations = [
                'title' => $translation->getTitle(),
                'fromEmail' => $translation->getFromEmail(),
                'fromName' => $translation->getFromName(),
                'toEmail' => $translation->getToEmail(),
                'toName' => $translation->getToName(),
                'subject' => $translation->getSubject(),
                'mailText' => $translation->getMailText(),
                'submitLabel' => $translation->getSubmitLabel(),
                'successText' => $translation->getSuccessText(),
                'sendAttachments' => $translation->getSendAttachments(),
                'deactivateNotifyMails' => $translation->getDeactivateNotifyMails(),
                'deactivateCustomerMails' => $translation->getDeactivateCustomerMails(),
                'receivers' => $receivers,
                'replyTo' => $translation->getReplyTo(),
            ];
        }

        // Fields
        $fields = [];

        foreach ($entity->getFields() as $field) {
            $fieldTranslation = $field->getTranslation($locale);

            $fieldData = [
                'id' => $field->getId(),
                'type' => $field->getType(),
                'key' => $field->getKey(),
                'required' => $field->getRequired(),
                'order' => $field->getOrder(),
                'width' => $field->getWidth(),
            ];

            if ($fieldTranslation) {
                $fieldData['title'] = $fieldTranslation->getTitle();
                $fieldData['placeholder'] = $fieldTranslation->getPlaceholder();
                $fieldData['defaultValue'] = $fieldTranslation->getDefaultValue();
                $fieldData['shortTitle'] = $fieldTranslation->getShortTitle();

                foreach ($fieldTranslation->getOptions() as $key => $option) {
                    $fieldData['options[' . $key . ']'] = $option;
                }
            }

            $fields[] = $fieldData;
        }

        // Api Entity
        return array_merge(
            [
                'id' => $entity->getId(),
                'locale' => $locale,
                'fields' => $fields,
            ],
            $translations
        );
    }
TODO use seralizer.

@param Form $entity
@param string $locale

@return array