Skip to content

Commit

Permalink
DP-460 Migrate to PHP 8.1/laravel 9
Browse files Browse the repository at this point in the history
- Remove SparkPost and Mandrill services from scripting service types
- Get rid of global helper functions
- Update dependencies
  • Loading branch information
daniilly committed Feb 27, 2023
1 parent 82ee8ef commit 7dfa68f
Show file tree
Hide file tree
Showing 10 changed files with 91 additions and 165 deletions.
7 changes: 5 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"dreamfactory/df-core": "~0.25",
"guzzlehttp/guzzle": "~6.0"
"dreamfactory/df-core": "~1.0",
"guzzlehttp/guzzle": "~7.2",
"symfony/mailer": "~6.1.7",
"symfony/mailgun-mailer": "~6.1.0",
"symfony/http-client": "~6.1.7"
},
"require-dev": {
"phpunit/phpunit": "@stable"
Expand Down
9 changes: 5 additions & 4 deletions src/Components/EmailUtilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace DreamFactory\Core\Email\Components;

use DreamFactory\Core\Exceptions\BadRequestException;
use \Illuminate\Support\Arr;

trait EmailUtilities
{
Expand All @@ -14,15 +15,15 @@ public static function sanitizeAndValidateEmails($emails, $return_format = '')
$out = array();
foreach ($emails as $info) {
if (is_array($info)) {
$email = array_get($info, 'email');
$email = Arr::get($info, 'email');
$email = filter_var($email, FILTER_SANITIZE_EMAIL);
if (false === filter_var($email, FILTER_VALIDATE_EMAIL)) {
throw new BadRequestException("Invalid email - '$email'.");
}
if (empty($email)) {
throw new BadRequestException('Email can not be empty.');
}
$name = array_get($info, 'name');
$name = Arr::get($info, 'name');
if (empty($name)) {
$out[] = $email;
} else {
Expand All @@ -48,15 +49,15 @@ public static function sanitizeAndValidateEmails($emails, $return_format = '')
}
} else // single pair
{
$email = array_get($emails, 'email');
$email = Arr::get($emails, 'email');
$email = filter_var($email, FILTER_SANITIZE_EMAIL);
if (false === filter_var($email, FILTER_VALIDATE_EMAIL)) {
throw new BadRequestException("Invalid email - '$email'.");
}
if (empty($email)) {
throw new BadRequestException('Email can not be empty.');
}
$name = array_get($emails, 'name');
$name = Arr::get($emails, 'name');
if (empty($name)) {
$out = $email;
} else {
Expand Down
6 changes: 3 additions & 3 deletions src/Models/MailGunConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ protected static function prepareConfigSchemaField(array &$schema)
case 'region_endpoint':
$schema['type'] = 'picklist';
$schema['values'] = [
['label' => 'United States', 'name' => 'api.mailgun.net'],
['label' => 'Europe', 'name' => 'api.eu.mailgun.net'],
['label' => 'United States', 'name' => ''],
['label' => 'Europe', 'name' => 'eu'],
];
$schema['default'] = 'api.mailgun.net';
$schema['default'] = '';
$schema['description'] = 'Select Mailgun service REST API Region Endpoint.
According to <a href="https://documentation.mailgun.com/en/latest/api-intro.html#mailgun-regions">Mailgun documentation</a>.';
break;
Expand Down
24 changes: 0 additions & 24 deletions src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,30 +57,6 @@ public function register()
return new MailGun($config);
},
]));
$df->addType(
new ServiceType(
[
'name' => 'mandrill_email',
'label' => 'Mandrill',
'description' => 'Mandrill email service',
'group' => ServiceTypeGroups::EMAIL,
'config_handler' => MandrillConfig::class,
'factory' => function ($config) {
return new Mandrill($config);
},
]));
$df->addType(
new ServiceType(
[
'name' => 'sparkpost_email',
'label' => 'SparkPost',
'description' => 'SparkPost email service',
'group' => ServiceTypeGroups::EMAIL,
'config_handler' => SparkpostConfig::class,
'factory' => function ($config) {
return new SparkPost($config);
},
]));
});
}

Expand Down
Loading

0 comments on commit 7dfa68f

Please sign in to comment.