protected function success() { /** @var User $owner */ $owner = $this->getDocumentsOwner(); $documents = $this->getExistDocuments($owner); $data = $this->form->getData(); foreach ($data as $key => $file) { if ($file instanceof UploadedFile) { if (isset($documents[$key])) { $document = $documents[$key]; } else { $document = new Document(); $documents[$key] = $document; } $document->setFile($file); $document->setType($key); $document->upload(); $this->addDocumentForOwner($owner, $document); if ($key == Document::TYPE_ADV || $key == Document::TYPE_INVESTMENT_MANAGEMENT_AGREEMENT) { $this->sendEmailMessages($owner, $key); } } } $this->em->persist($owner); $this->em->flush(); }
protected function success() { $user = $this->getOption('user'); if (!$user instanceof User) { throw new \InvalidArgumentException(sprintf('Option user must be instance of %s', get_class(new User()))); } /** @var RiaCompanyInformation $data */ $data = $this->form->getData(); $existDocuments = $this->getExistDocuments($user); $documentFiles = $this->form->get('documents')->getData(); foreach ($documentFiles as $key => $file) { if (isset($existDocuments[$key])) { $document = $existDocuments[$key]; } else { $document = new Document(); $existDocuments[$key] = $document; } $document->setFile($file); $document->setType($key); $document->setOwnerId($user->getId()); $document->upload(); if (!$user->getUserDocuments()->contains($document)) { $user->addUserDocument($document); } } $data->setRia($user); $this->em->persist($data); $this->em->persist($user); $this->em->flush(); }
public function success() { $emailService = $this->getOption('email_service'); if (!$emailService instanceof MailerInterface) { throw new \InvalidArgumentException(sprintf('Option email_service must be instance of Wealthbot\\MailerBundle\\Mailer\\MailerInterface')); } /** @var RiaCompanyInformation $riaCompanyInformation */ $riaCompanyInformation = $this->form->getData(); /** @var User $ria */ $ria = $riaCompanyInformation->getRia(); $documents = $this->getExistDocuments($ria); $documentFormData = $this->form->get('documents')->getData(); if ($documentFormData) { foreach ($documentFormData as $key => $file) { if ($file instanceof UploadedFile) { if (isset($documents[$key])) { $document = $documents[$key]; } else { $document = new Document(); $documents[$key] = $document; } $document->setFile($file); $document->setType($key); $document->upload(); $this->addDocumentForOwner($ria, $document); if ($key == Document::TYPE_ADV || $key == Document::TYPE_INVESTMENT_MANAGEMENT_AGREEMENT) { $this->sendEmailMessages($ria, $key, $emailService); } } } } $this->em->persist($ria); $this->em->persist($riaCompanyInformation); $this->em->flush(); }