Example #1
0
 /**
  * Generates the Mail Body
  */
 protected function generateBody()
 {
     $message = new Mime\Message();
     $text = $this->generateHtml();
     $textPart = new Mime\Part($text);
     $textPart->type = 'text/html';
     $textPart->charset = 'UTF-8';
     $textPart->disposition = Mime\Mime::DISPOSITION_INLINE;
     $message->addPart($textPart);
     if (isset($this->application->getContact()->image) && $this->application->getContact()->getImage()->id) {
         /* @var $image \Auth\Entity\UserImage */
         $image = $this->application->getContact()->getImage();
         $part = new Mime\Part($image->getResource());
         $part->type = $image->type;
         $part->encoding = Mime\Mime::ENCODING_BASE64;
         $part->filename = $image->name;
         $part->disposition = Mime\Mime::DISPOSITION_ATTACHMENT;
         $message->addPart($part);
     }
     foreach ($this->application->getAttachments() as $attachment) {
         /* @var $part \Applications\Entity\Attachment */
         $part = new Mime\Part($attachment->getResource());
         $part->type = $attachment->type;
         $part->encoding = Mime\Mime::ENCODING_BASE64;
         $part->filename = $attachment->name;
         $part->disposition = Mime\Mime::DISPOSITION_ATTACHMENT;
         $message->addPart($part);
     }
     $this->setBody($message);
 }
Example #2
0
 /**
  * @param Application $application
  * @param UserInterface $user
  * @return CvEntity
  * @since 0.26
  */
 public function createFromApplication(Application $application, UserInterface $user)
 {
     $cv = $this->create();
     $cv->setContact($application->getContact());
     $assignedUser = $application->getJob()->getUser();
     $cv->setUser($assignedUser);
     $perms = $cv->getPermissions();
     $perms->inherit($application->getPermissions());
     // grant view permission to the user that issued this creation.
     $perms->grant($user, PermissionsInterface::PERMISSION_VIEW);
     // revoke change permission to the original applicant
     $perms->revoke($application->getUser(), PermissionsInterface::PERMISSION_CHANGE);
     $applicationAttachments = $application->getAttachments();
     if (count($applicationAttachments) > 0) {
         $cvAttachments = [];
         /* @var $applicationAttachment \Applications\Entity\Attachment */
         foreach ($applicationAttachments as $applicationAttachment) {
             $file = new \Doctrine\MongoDB\GridFSFile();
             $file->setBytes($applicationAttachment->getContent());
             $cvAttachment = new \Cv\Entity\Attachment();
             $cvAttachment->setName($applicationAttachment->getName());
             $cvAttachment->setType($applicationAttachment->getType());
             $cvAttachment->setUser($assignedUser);
             $cvAttachment->setFile($file);
             $cvAttachment->setDateUploaded($applicationAttachment->getDateUploaded());
             $cvAttachments[] = $cvAttachment;
         }
         $cv->setAttachments(new \Doctrine\Common\Collections\ArrayCollection($cvAttachments));
     }
     return $cv;
 }
Example #3
0
 public function testGetAttachmentsWithoutAttachments()
 {
     $this->assertEquals(new ArrayCollection(), $this->target->getAttachments());
 }