Skip to content

Commit

Permalink
WIP: SF5 Compatibility, Drop FOS USER
Browse files Browse the repository at this point in the history
  • Loading branch information
BadPixxel committed Sep 27, 2023
1 parent 11bca14 commit 8d71ea0
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 26 deletions.
22 changes: 13 additions & 9 deletions src/Models/AbstractEmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@
* file that was distributed with this source code.
*/

namespace BadPixxel\SendinblueBridge\Models;
namespace BadPixxel\BrevoBridge\Models;

use BadPixxel\SendinblueBridge\Services\SmtpManager;
use BadPixxel\BrevoBridge\Services\SmtpManager;
use Brevo\Client\Model\CreateSmtpEmail;
use Brevo\Client\Model\SendSmtpEmail;
use Brevo\Client\Model\SendSmtpEmailSender;
use Exception;
use SendinBlue\Client\Model\CreateSmtpEmail;
use SendinBlue\Client\Model\SendSmtpEmail;
use Sonata\UserBundle\Model\UserInterface as User;
use Symfony\Component\EventDispatcher\GenericEvent;
use Symfony\Component\OptionsResolver\OptionsResolver;
Expand All @@ -31,28 +32,28 @@ abstract class AbstractEmail extends GenericEvent
*
* @var User[]
*/
protected $toUsers;
protected array $toUsers;

/**
* Current Email.
*
* @var SendSmtpEmail
*/
protected $email;
protected SendSmtpEmail $email;

/**
* Default Parameters.
*
* @var array
*/
protected $paramsDefaults = array();
protected array $paramsDefaults = array();

/**
* Default Parameters Types.
*
* @var array
*/
protected $paramsTypes = array();
protected array $paramsTypes = array();

/**
* Construct Minimal Email.
Expand All @@ -61,6 +62,7 @@ abstract class AbstractEmail extends GenericEvent
*/
public function __construct($toUsers)
{
parent::__construct();
$this
->create()
->setupToUsers($toUsers)
Expand Down Expand Up @@ -88,6 +90,7 @@ public static function send($toUsers): ?CreateSmtpEmail
// Create a New Instance of the Email
/** @var AbstractEmail $instance */
$instance = call_user_func_array($callback, func_get_args());

//==============================================================================
// Create a New Instance of the Email
return $instance->sendEmail(false);
Expand All @@ -114,6 +117,7 @@ public static function sendDemo($toUsers): ?CreateSmtpEmail
// Create a New Instance of the Email
/** @var AbstractEmail $instance */
$instance = call_user_func_array($callback, func_get_args());

//==============================================================================
// Create a New Instance of the Email
return $instance->sendEmail(true);
Expand Down Expand Up @@ -323,7 +327,7 @@ private function isValid(): bool
{
//==============================================================================
// Verify Sender
/** @var null|\SendinBlue\Client\Model\SendSmtpEmailSender $sender */
/** @var null|SendSmtpEmailSender $sender */
$sender = $this->email->getSender();
if (empty($sender)) {
return false;
Expand Down
10 changes: 5 additions & 5 deletions src/Models/AbstractEmailAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* file that was distributed with this source code.
*/

namespace BadPixxel\SendinblueBridge\Models;
namespace BadPixxel\BrevoBridge\Models;

use Sonata\AdminBundle\Admin\AbstractAdmin as Admin;
use Sonata\AdminBundle\Datagrid\DatagridInterface;
Expand All @@ -34,7 +34,7 @@ protected function configureActionButtons(array $buttonList, string $action, ?ob
{
$list = parent::configureActionButtons($buttonList, $action, $object);

$list['refresh']['template'] = '@SendinblueBridge/Admin/action_refresh.html.twig';
$list['refresh']['template'] = '@BrevoBridge/Admin/action_refresh.html.twig';

return $list;
}
Expand Down Expand Up @@ -99,7 +99,7 @@ protected function configureListFields(ListMapper $list): void
'actions' => array(
'show' => array(),
'refresh' => array(
'template' => '@SendinblueBridge/Admin/list__action_email_refresh.html.twig',
'template' => '@BrevoBridge/Admin/list__action_email_refresh.html.twig',
)
),
))
Expand Down Expand Up @@ -141,7 +141,7 @@ protected function configureShowFields(ShowMapper $show): void
$show
->with('Contents', array('class' => 'col-md-8'))
->add('htmlContent', null, array(
'template' => '@SendinblueBridge/Admin/html_content.html.twig',
'template' => '@BrevoBridge/Admin/html_content.html.twig',
))
->end()
->with('Metadatas', array('class' => 'col-md-4'))
Expand All @@ -152,7 +152,7 @@ protected function configureShowFields(ShowMapper $show): void
->add('messageId')
->add('uuid')
->add('events', null, array(
'template' => '@SendinblueBridge/Admin/events_list.html.twig',
'template' => '@BrevoBridge/Admin/events_list.html.twig',
))
->end()
;
Expand Down
10 changes: 6 additions & 4 deletions src/Models/AbstractSms.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
* file that was distributed with this source code.
*/

namespace BadPixxel\SendinblueBridge\Models;
namespace BadPixxel\BrevoBridge\Models;

use BadPixxel\SendinblueBridge\Services\SmsManager;
use BadPixxel\BrevoBridge\Services\SmsManager;
use Brevo\Client\Model\SendSms;
use Brevo\Client\Model\SendTransacSms;
use Exception;
use SendinBlue\Client\Model\SendSms;
use SendinBlue\Client\Model\SendTransacSms;
use Sonata\UserBundle\Model\UserInterface as User;
use Symfony\Component\OptionsResolver\OptionsResolver;

Expand Down Expand Up @@ -94,6 +94,7 @@ public static function send(User $user): ?SendSms
// Create a New Instance of the Email
/** @var AbstractSms $instance */
$instance = call_user_func_array($callback, func_get_args());

//==============================================================================
// Create a New Instance of the Sms
return $instance->sendSms(false);
Expand All @@ -120,6 +121,7 @@ public static function sendDemo(User $user): ?SendSms
// Create a New Instance of the Email
/** @var AbstractSms $instance */
$instance = call_user_func_array($callback, func_get_args());

//==============================================================================
// Create a New Instance of the Sms
return $instance->sendSms(true);
Expand Down
2 changes: 1 addition & 1 deletion src/Models/User/EmailsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* file that was distributed with this source code.
*/

namespace BadPixxel\SendinblueBridge\Models\User;
namespace BadPixxel\BrevoBridge\Models\User;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
Expand Down
2 changes: 1 addition & 1 deletion src/Models/User/SmsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* file that was distributed with this source code.
*/

namespace BadPixxel\SendinblueBridge\Models\User;
namespace BadPixxel\BrevoBridge\Models\User;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
Expand Down
4 changes: 1 addition & 3 deletions src/Models/UserEmails/ContentsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@
* file that was distributed with this source code.
*/

namespace BadPixxel\SendinblueBridge\Models\UserEmails;
namespace BadPixxel\BrevoBridge\Models\UserEmails;

use Doctrine\ORM\Mapping as ORM;

/**
* Storage of Email Contents.
*
* @author nanard33
*/
trait ContentsTrait
{
Expand Down
6 changes: 3 additions & 3 deletions src/Models/UserEmails/MetadataTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
* file that was distributed with this source code.
*/

namespace BadPixxel\SendinblueBridge\Models\UserEmails;
namespace BadPixxel\BrevoBridge\Models\UserEmails;

use Brevo\Client\Model\GetEmailEventReportEvents;
use Brevo\Client\Model\GetEmailEventReportEvents as Event;
use DateTime;
use Doctrine\ORM\Mapping as ORM;
use Exception;
use SendinBlue\Client\Model\GetEmailEventReportEvents;
use SendinBlue\Client\Model\GetEmailEventReportEvents as Event;

/**
* Emails Storage Metadata.
Expand Down

0 comments on commit 8d71ea0

Please sign in to comment.