/**
  * Sends a message to the admin based on the given type
  *
  * @param \DERHANSEN\SfEventMgt\Domain\Model\Event $event Event
  * @param \DERHANSEN\SfEventMgt\Domain\Model\Registration $registration Registration
  * @param array $settings Settings
  * @param int $type Type
  *
  * @return bool TRUE if successful, else FALSE
  */
 public function sendAdminMessage($event, $registration, $settings, $type)
 {
     list($template, $subject) = $this->getAdminMessageTemplateSubject($settings, $type);
     if (is_null($event) || is_null($registration || !is_array($settings)) || $event->getNotifyAdmin() === false && $event->getNotifyOrganisator() === false) {
         return false;
     }
     $allEmailsSent = true;
     $body = $this->getNotificationBody($event, $registration, $template, $settings);
     $attachments = $this->attachmentService->getAttachments($settings, $registration, $type, MessageRecipient::ADMIN);
     if ($event->getNotifyAdmin()) {
         $adminEmailArr = GeneralUtility::trimExplode(',', $settings['notification']['adminEmail'], true);
         foreach ($adminEmailArr as $adminEmail) {
             $allEmailsSent = $allEmailsSent && $this->emailService->sendEmailMessage($settings['notification']['senderEmail'], $adminEmail, $subject, $body, $settings['notification']['senderName'], $attachments);
         }
     }
     if ($event->getNotifyOrganisator() && $event->getOrganisator()) {
         $allEmailsSent = $allEmailsSent && $this->emailService->sendEmailMessage($settings['notification']['senderEmail'], $event->getOrganisator()->getEmail(), $subject, $body, $settings['notification']['senderName'], $attachments);
     }
     return $allEmailsSent;
 }
 /**
  * Tests if fromRegistrationProperty returns expected attachments for FileReference property
  * @test
  */
 public function getAttachmentsReturnsAttachmentsFromEventPropertyWithFileReference()
 {
     $event = new \DERHANSEN\SfEventMgt\Domain\Model\Event();
     $mockFile = $this->getMock('TYPO3\\CMS\\Core\\Resource\\File', ['getForLocalProcessing'], [], '', false);
     $mockFile->expects($this->any())->method('getForLocalProcessing')->will($this->returnValue('/path/to/somefile.pdf'));
     $mockFileRef = $this->getMock('TYPO3\\CMS\\Extbase\\Domain\\Model\\FileReference', ['getOriginalResource'], [], '', false);
     $mockFileRef->expects($this->any())->method('getOriginalResource')->will($this->returnValue($mockFile));
     $mockRegistration = $this->getMock('DERHANSEN\\SfEventMgt\\Domain\\Model\\Registration', ['getEvent', '_hasProperty', '_getProperty'], [], '', false);
     $mockRegistration->expects($this->once())->method('getEvent')->will($this->returnValue($event));
     $mockRegistration->expects($this->once())->method('_hasProperty')->will($this->returnValue(true));
     $mockRegistration->expects($this->once())->method('_getProperty')->will($this->returnValue($mockFileRef));
     $settings = ['notification' => ['registrationNew' => ['attachments' => ['user' => ['fromRegistrationProperty' => ['fileProperty']]]]]];
     $expected = ['/path/to/somefile.pdf'];
     $attachments = $this->subject->getAttachments($settings, $mockRegistration, MessageType::REGISTRATION_NEW, MessageRecipient::USER);
     $this->assertEquals($expected, $attachments);
 }