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(); }
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(); }
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(); }
public function createDocument($fileName, $path, $type, $ref) { $document = new Document(); copy(__DIR__ . '/../../Resources/public/pdf/' . $fileName, $path . '/' . $fileName); $document->setMimeType('application/pdf'); $document->setOriginalName($fileName); $document->setFilename($fileName); $document->setType($type); $this->addReference($ref, $document); return $document; }
/** * Create new document signature * * @param int $sourceId * @param string $type * @param string|null $envelopeId * @param string $status * @return DocumentSignature */ public function createDocumentSignature($sourceId, $type, $envelopeId = null, $status = Envelope::STATUS_CREATED) { $document = new Document(); $document->setType(Document::TYPE_APPLICATION); $signature = new DocumentSignature(); $signature->setSourceId($sourceId); $signature->setDocument($document); $signature->setDocusignEnvelopeId($envelopeId); $signature->setType($type); $signature->setStatus($status); $signature->setActive(true); return $signature; }