예제 #1
0
 /**
  * Returns an array of filenames to attach to notifications
  *
  * Attachments must be configured as following (example for "registrationNew"):
  *
  *  registrationNew {
  *    attachments {
  *      user {
  *        fromFiles {
  *          1 = fileadmin/path-to-attachment.pdf
  *        }
  *        fromEventProperty {
  *          1 = files
  *          2 = image
  *        }
  *        fromRegistrationProperty {
  *          1 = propertyOfRegistration
  *        }
  *      }
  *      admin {
  *        fromFiles =
  *        fromEventProperty =
  *        fromRegistrationProperty =
  *      }
  *   }
  * }
  *
  * @param array $settings
  * @param Registration $registration
  * @param int $messageType
  * @param string $messageRecipient
  *
  * @return array Array with absolute filenames to attachments
  */
 public function getAttachments($settings, $registration, $messageType, $messageRecipient)
 {
     $attachments = [];
     $settingPath = '';
     switch ($messageType) {
         case MessageType::REGISTRATION_NEW:
             $settingPath = 'registrationNew';
             break;
         case MessageType::REGISTRATION_WAITLIST_NEW:
             $settingPath = 'registrationWaitlistNew';
             break;
         case MessageType::REGISTRATION_CONFIRMED:
             $settingPath = 'registrationConfirmed';
             break;
         case MessageType::REGISTRATION_WAITLIST_CONFIRMED:
             $settingPath = 'registrationWaitlistConfirmed';
             break;
     }
     if (isset($settings['notification'][$settingPath]['attachments'][$messageRecipient])) {
         // Attachments globally from TypoScript
         $config = $settings['notification'][$settingPath]['attachments'][$messageRecipient];
         $attachments = $this->getFileAttachments($config);
         // Attachments from Event properties
         $eventAttachments = $this->getObjectAttachments($config['fromEventProperty'], $registration->getEvent());
         $attachments = array_merge($attachments, $eventAttachments);
         // Attachments from Registration properties
         $registrationAttachments = $this->getObjectAttachments($config['fromRegistrationProperty'], $registration);
         $attachments = array_merge($attachments, $registrationAttachments);
     }
     return $attachments;
 }
예제 #2
0
 /**
  * Checks if the given action can be called for the given registration / event and throws
  * an exception if action should not proceed
  *
  * @param \DERHANSEN\SfEventMgt\Domain\Model\Registration $registration
  * @param string $actionName
  * @throws PaymentException
  * @return void
  */
 protected function proceedWithAction($registration, $actionName)
 {
     if ($registration->getEvent()->getEnablePayment() === false) {
         $message = LocalizationUtility::translate('payment.messages.paymentNotEnabled', 'sf_event_mgt');
         throw new PaymentException($message, 1899934881);
     }
     if ($this->paymentService->paymentActionEnabled($registration->getPaymentmethod(), $actionName) === false) {
         $message = LocalizationUtility::translate('payment.messages.actionNotEnabled', 'sf_event_mgt');
         throw new PaymentException($message, 1899934882);
     }
     if ($registration->getPaid()) {
         $message = LocalizationUtility::translate('payment.messages.paymentAlreadyProcessed', 'sf_event_mgt');
         throw new PaymentException($message, 1899934883);
     }
     if ($registration->getEvent()->getRestrictPaymentMethods()) {
         $selectedPaymentMethods = explode(',', $registration->getEvent()->getSelectedPaymentMethods());
         if (!in_array($registration->getPaymentmethod(), $selectedPaymentMethods)) {
             $message = LocalizationUtility::translate('payment.messages.paymentMethodNotAvailable', 'sf_event_mgt');
             throw new PaymentException($message, 1899934884);
         }
     }
 }
 /**
  * Returns, if payment redirect for the payment method is enabled
  *
  * @param Registration $registration
  * @return bool
  */
 public function redirectPaymentEnabled($registration)
 {
     if ($registration->getEvent()->getEnablePayment() === false) {
         return false;
     }
     /** @var AbstractPayment $paymentInstance */
     $paymentInstance = $this->paymentService->getPaymentInstance($registration->getPaymentmethod());
     if ($paymentInstance !== null && $paymentInstance->isRedirectEnabled()) {
         return true;
     } else {
         return false;
     }
 }
예제 #4
0
 /**
  * @test
  * @return void
  */
 public function setEventForEventSetsEvent()
 {
     $event = new \DERHANSEN\SfEventMgt\Domain\Model\Event();
     $this->subject->setEvent($event);
     $this->assertEquals($event, $this->subject->getEvent());
 }