G
G
gitdev2021-02-04 22:45:15
symfony
gitdev, 2021-02-04 22:45:15

Is it correct to pass the FormInterface $form to the Service, or is it better to pass a specific data type?

There is a service that is responsible for creating a new candidate and it has image uploads. Is it correct to send the form to the service?

public function manage(<b>FormInterface $form</b>, Proposition $proposition, Candidate $candidate): bool
    {

<b>        if ($file = $form->get('file_cv')->getData()) {
</b>            $newFileName = $this->uploader->upload($file);

            if (!$newFileName) {
                return false;
            }

            $candidate->setFileCv($newFileName);
        }

        $this->saveCandidate($candidate, $proposition);

        return true;
    }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question