public function sendInvoiceEmail(Document $invoice, Parameters $data, $documentFile)
 {
     $companyFiles = array();
     $params = new Parameters();
     if (isset($data->smtp) && $data->smtp > 0) {
         $smtp = $this->getOneObjectByField(SmtpOptions::getClass(), 'id', $data->smtp);
         $params->transport = $smtp->getTransport();
     }
     $params->from = $data->from;
     $params->to = $data->to;
     $params->header = $data->header;
     $params->content = $data->content;
     $params->documentFile = $documentFile;
     if (isset($data->companyFiles)) {
         foreach ($data->companyFiles as $id) {
             $companyFile = $this->getOneObjectByField(Company\File::getClass(), 'id', $id);
             $companyFiles[] = $companyFile;
         }
     }
     $params->companyFiles = $companyFiles;
     $this->mailService->sendInvoiceWithParams($invoice, $params);
 }
 public function getSmtpById($id)
 {
     return $this->entityManager->getRepository(SmtpOptions::getClass())->findOneBy(array('id' => $id));
 }