public function index()
 {
     $paymentData = $this->getPaymentSettings();
     if ($this->isRequestMethod('post') && ($settings = $this->getRequest()->request->get('settings'))) {
         $settings = Arr::remove($settings, array_keys($paymentData));
         $saved_settings = 0;
         $systemSettingsModel = $this->get('core.system.settings.model');
         foreach ($settings as $setting => $value) {
             $systemSettingsModel->setData($setting, $value);
             $saved_settings++;
         }
         if ($saved_settings) {
             $this->addFlash(lang('payment_update_success'), 'success');
             redirect(current_url());
         }
     }
     $geteways = Payment_gateways::findAll();
     $this->template->set('geteways', $geteways);
     $this->template->set('paymentData', $paymentData);
     $this->template->render();
 }
 /**
  * Build Mailgun compatible message array from email entity
  *
  * Documentation at https://mandrillapp.com/api/docs/messages.php.html
  *
  * @param  EmailEntity  $emails
  * @return array
  */
 protected function buildMessage(EmailEntity $email)
 {
     // Create attachments array
     $attachments = json_decode($email->getAttachments(), true) ?: [];
     // Convert Mandrill format to Mailgun format
     $attachments = array_map(function ($attachment) {
         if (isset($attachment['content'])) {
             $attachment['data'] = base64_decode(Arr::remove($attachment, 'content'));
         }
         if (isset($attachment['name'])) {
             $attachment['filename'] = Arr::remove($attachment, 'name');
         }
         if (isset($attachment['type'])) {
             $attachment['contentType'] = Arr::remove($attachment, 'type');
         }
         return attachment;
     }, $attachments);
     if ($email->getSenderName()) {
         $from = "{$email->getSenderName()} <{$email->getSenderEmail()}>";
     } else {
         $from = $email->getSenderEmail();
     }
     if ($email->getTemplateName()) {
         $html = $this->templateService->renderHbsForEmail($email->getTemplateName(), $email->getTemplateData() ? json_decode($email->getTemplateData(), true) : []);
     } else {
         $html = $email->getMessage();
     }
     $message = ['html' => $html, 'subject' => $email->getSubject(), 'from' => $from, 'to' => $this->filterThroughWhitelist($email->getRecipientEmail()), 'attachments' => $attachments];
     if ($email->getHeaders()) {
         $headers = [];
         foreach (json_decode($email->getHeaders(), true) as $key => $value) {
             $headers["h:{$key}"] = $value;
         }
         $message['headers'] = $headers;
     }
     return $message;
 }
Example #3
0
 /**
  * Remove an array entry by path
  *
  * @param $array array Source
  * @param $path array|string Path to the key you'd want to unset
  * @param null $delimiter
  * @return bool
  */
 public static function remove(&$array, $path, $delimiter = NULL)
 {
     if (!Arr::is_array($array)) {
         // This is not an array!
         return false;
     }
     if (is_array($path)) {
         // The path has already been separated into keys
         $keys = $path;
     } else {
         if (array_key_exists($path, $array)) {
             // No need to do extra processing
             unset($array[$path]);
             return true;
         }
         if ($delimiter === NULL) {
             // Use the default delimiter
             $delimiter = Arr::$delimiter;
         }
         // Remove starting delimiters and spaces
         $path = ltrim($path, "{$delimiter} ");
         // Remove ending delimiters, spaces, and wildcards
         $path = rtrim($path, "{$delimiter} *");
         // Split the keys by delimiter
         $keys = explode($delimiter, $path);
     }
     do {
         $key = array_shift($keys);
         if (ctype_digit($key)) {
             // Make the key an integer
             $key = (int) $key;
         }
         if (isset($array[$key])) {
             if ($keys) {
                 if (Arr::is_array($array[$key])) {
                     // Dig down into the next part of the path
                     $array = $array[$key];
                 } else {
                     // Unable to dig deeper
                     break;
                 }
             } else {
                 // Found the path requested
                 unset($array[$key]);
                 return true;
             }
         } elseif ($key === '*') {
             // Handle wildcards
             $success = false;
             foreach ($array as $arr) {
                 if (Arr::remove($arr, implode('.', $keys))) {
                     $success = true;
                 }
             }
             return $success;
         } else {
             // Unable to dig deeper
             break;
         }
     } while ($keys);
     // Unable to find the value requested
     return false;
 }
Example #4
0
 /**
  * Removes a param using "dot notation" from the session.
  *
  * @param string $path
  *
  * @throws \LogicException If the session has not been started yet
  *
  * @return bool
  */
 public final function remove($path)
 {
     if (!$this->started()) {
         throw new LogicException('The session has not been started yet.');
     }
     return Arr::remove($this->data, $path);
 }
 protected function _requiredFieldValidate()
 {
     $requiredFields = $this->getRequiredFields();
     $requiredFieldsInfo = $this->getRequiredFieldsInfo();
     $data = Arr::remove($this->getDecodedData(), $requiredFields);
     if (count($data) != count($requiredFields)) {
         return 'All fields are required!';
     }
     foreach ($data as $key => $value) {
         $fieldInfo = $requiredFieldsInfo[$key];
         if ($fieldInfo->isRequired() && strlen($value) == 0) {
             return sprintf('Field %s is required.', $fieldInfo->GetLabel());
         }
     }
 }
Example #6
0
 /**
  * Removes one or more values.
  *
  * @param  array|string $keys
  * @return self
  */
 public function remove($keys)
 {
     Arr::remove($this->values, $keys);
     return $this;
 }