Ojs\ApiBundle\Handler\JournalArticleHandler::processForm PHP Méthode

processForm() private méthode

Processes the form.
private processForm ( Article $entity, array $parameters, String $method = "PUT" ) : Article
$entity Ojs\JournalBundle\Entity\Article
$parameters array
$method String
Résultat Ojs\JournalBundle\Entity\Article
    private function processForm(Article $entity, array $parameters, $method = "PUT")
    {
        $journal = $this->journalService->getSelectedJournal();
        $form = $this->formFactory->create(new ArticleType(), $entity, ['method' => $method, 'csrf_protection' => false, 'journal' => $journal]);
        $form->add('status', NumberType::class);
        $form->submit($parameters, 'PATCH' !== $method);
        $formData = $form->getData();
        $header = $formData->getHeader();
        if (isset($header)) {
            $entity->setHeader($this->storeFile($header, true));
        }
        if ($form->isValid()) {
            $entity->setCurrentLocale('en');
            $entity->setJournal($this->journalService->getSelectedJournal());
            $this->om->persist($entity);
            $this->om->flush();
            return $formData;
        }
        throw new InvalidFormException('Invalid submitted data', $form);
    }