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 Apr 24, 2023
1 parent d347748 commit 19cee94
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 13 deletions.
14 changes: 11 additions & 3 deletions src/Models/AbstractEmail.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@

use BadPixxel\SendinblueBridge\Services\SmtpManager;
use Exception;
use FOS\UserBundle\Model\UserInterface as User;
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 Down Expand Up @@ -158,6 +158,8 @@ protected function create(): self
/**
* Create a New Email and Populate Defaults Values.
*
* @throws Exception
*
* @return null|CreateSmtpEmail
*/
protected function sendEmail(bool $demoMode): ?CreateSmtpEmail
Expand All @@ -179,6 +181,8 @@ protected function sendEmail(bool $demoMode): ?CreateSmtpEmail
/**
* Add User to Email To.
*
* @param User $toUser
*
* @return self
*/
protected function addToUser(User $toUser): self
Expand All @@ -191,6 +195,8 @@ protected function addToUser(User $toUser): self
/**
* Add User to Email Cc.
*
* @param User $ccUser
*
* @return self
*/
protected function addCcUser(User $ccUser): self
Expand All @@ -203,6 +209,8 @@ protected function addCcUser(User $ccUser): self
/**
* Add User to Email Bcc.
*
* @param User $bccUser
*
* @return self
*/
protected function addBccUser(User $bccUser): self
Expand Down Expand Up @@ -285,7 +293,7 @@ private static function addUserEmail(?array $emailList, User $toUser): array
// Extract User Name
$name = method_exists($toUser, "__toString")
? $toUser->__toString()
: $toUser->getUsername()
: $toUser->getUserIdentifier()
;
//==============================================================================
// Create To User Array
Expand All @@ -295,7 +303,7 @@ private static function addUserEmail(?array $emailList, User $toUser): array
));
//==============================================================================
// Push User to List
if (is_null($emailList) || empty($emailList)) {
if (empty($emailList)) {
return $emailUser;
}

Expand Down
Empty file modified src/Models/AbstractEmailAdmin.php
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion src/Models/AbstractSms.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@

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

/**
Expand Down
Empty file modified src/Models/AbstractSmsAdmin.php
100644 → 100755
Empty file.
22 changes: 13 additions & 9 deletions src/Models/AbstractTrackEvent.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

use BadPixxel\SendinblueBridge\Services\EventManager;
use Exception;
use FOS\UserBundle\Model\UserInterface as User;
use Sonata\UserBundle\Model\UserInterface as User;
use Symfony\Component\OptionsResolver\OptionsResolver;

/**
Expand All @@ -28,28 +28,28 @@ abstract class AbstractTrackEvent
*
* @var string
*/
protected $type = "myEventCode";
protected string $type = "myEventCode";

/**
* User Email.
*
* @var string
*/
protected $userEmail;
protected string $userEmail;

/**
* Default Properties.
*
* @var array
*/
protected $propertiesDefaults = array();
protected array $propertiesDefaults = array();

/**
* Default Event Data.
*
* @var array
*/
protected $eventDataDefaults = array();
protected array $eventDataDefaults = array();

/**
* Event Properties.
Expand All @@ -59,7 +59,7 @@ abstract class AbstractTrackEvent
*
* @var null|array<string, string>
*/
private $properties;
private ?array $properties;

/**
* Event Data.
Expand All @@ -69,7 +69,7 @@ abstract class AbstractTrackEvent
*
* @var null|array<string, string>
*/
private $eventdata;
private ?array $eventdata;

/**
* Construct the Event.
Expand Down Expand Up @@ -110,10 +110,12 @@ public static function send(User $user): bool
}

/**
* Send a Transactionnal Test/Demo Event.
* Send a Transactional Test/Demo Event.
*
* @param User $user Target User
*
* @throws Exception
*
* @return bool
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
Expand Down Expand Up @@ -171,11 +173,13 @@ public static function getLastError(): string
/**
* Set Event User
*
* @param User $user
*
* @return self
*/
public function setUser(User $user): self
{
$this->userEmail = $user->getEmailCanonical();
$this->userEmail = (string) $user->getEmailCanonical();

return $this;
}
Expand Down
Empty file modified src/Models/User/EmailsTrait.php
100644 → 100755
Empty file.
Empty file modified src/Models/User/SmsTrait.php
100644 → 100755
Empty file.
Empty file modified src/Models/UserEmails/ContentsTrait.php
100644 → 100755
Empty file.
Empty file modified src/Models/UserEmails/MetadataTrait.php
100644 → 100755
Empty file.

0 comments on commit 19cee94

Please sign in to comment.