Skip to content

Commit

Permalink
Fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
cannycookie authored and github-actions[bot] committed Jul 8, 2023
1 parent f54c23c commit 96c0067
Show file tree
Hide file tree
Showing 41 changed files with 286 additions and 277 deletions.
1 change: 1 addition & 0 deletions .php-cs-fixer.cache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"php":"8.2.7","version":"3.20.0","indent":" ","lineEnding":"\n","rules":{"blank_line_after_opening_tag":true,"blank_line_between_import_groups":true,"blank_lines_before_namespace":true,"class_definition":{"inline_constructor_arguments":false,"space_before_parenthesis":true},"compact_nullable_typehint":true,"curly_braces_position":{"allow_single_line_empty_anonymous_classes":true},"declare_equal_normalize":true,"lowercase_cast":true,"lowercase_static_reference":true,"new_with_braces":true,"no_blank_lines_after_class_opening":true,"no_leading_import_slash":true,"no_whitespace_in_blank_line":true,"ordered_class_elements":{"order":["use_trait"]},"ordered_imports":{"sort_algorithm":"alpha"},"return_type_declaration":true,"short_scalar_cast":true,"single_import_per_statement":{"group_to_single_imports":false},"single_trait_insert_per_statement":true,"ternary_operator_spaces":true,"visibility_required":true,"blank_line_after_namespace":true,"constant_case":true,"control_structure_braces":true,"control_structure_continuation_position":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"method_argument_space":{"on_multiline":"ensure_fully_multiline","keep_multiple_spaces_after_comma":true},"no_break_comment":true,"no_closing_tag":true,"no_multiple_statements_per_line":true,"no_space_around_double_colon":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_line_after_imports":true,"statement_indentation":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"encoding":true,"full_opening_tag":true,"array_syntax":{"syntax":"short"},"no_unused_imports":true,"not_operator_with_successor_space":true,"trailing_comma_in_multiline":true,"phpdoc_scalar":true,"unary_operator_spaces":true,"binary_operator_spaces":true,"blank_line_before_statement":{"statements":["break","continue","declare","return","throw","try"]},"phpdoc_single_line_var_spacing":true,"phpdoc_var_without_name":true,"class_attributes_separation":{"elements":{"method":"one"}}},"hashes":{"src\/Mail\/UserLoginEmail.php":"329a82853b7d999ca83727ae4cfe4ad7","src\/Mail\/UserPasswordResetSuccessEmail.php":"424196536f4b5c1e732f0af0e4e20508","src\/Mail\/UserRequestPasswordResetEmail.php":"34697e6c43ac925f55457164ca3e824b","src\/Mail\/UserLockedOutEmail.php":"39c1e1953ca1fde457d8abb4e72c8cbe","src\/Mail\/UserRegisteredEmail.php":"1c340bc2c746d72b6bc467a531c4d88c","src\/Mail\/UserVerifiedEmail.php":"9586f0b8e9abc2d521df9bae4705677d","src\/Mail\/UserVerifyEmail.php":"0a7307753eae99b4ba2d7e028898d216","src\/Models\/EmailTemplate.php":"e450f46e8c68fe385ca92cbd9ca970b4","src\/Components\/SelectLanguage.php":"071f37f6f3e8f679598e08e7c4d56c69","src\/Components\/Iframe.php":"9f0ced5dd4f7d11a7d27624fcfd819d0","src\/EmailTemplatesServiceProvider.php":"12d61b0961bf00e887bd1916b28dd9c7","src\/EmailTemplatesEventServiceProvider.php":"e3b0e4919fdb2b75f52385234169afcd","src\/Listeners\/UserLockoutListener.php":"e48c86c86ea131c8dfc3e28585a5c20a","src\/Listeners\/UserRegisteredListener.php":"642372800010a71b7d294ad2c516afde","src\/Listeners\/UserLoginListener.php":"03e01dafc269e0296e243299bc02b2b7","src\/Listeners\/PasswordResetListener.php":"c834264e4c49a4ab9aaedfff3566e95b","src\/Listeners\/UserVerifiedListener.php":"c31c7a93b6f384b38524f965528b7893","src\/Notifications\/UserPasswordResetNotification.php":"ed76d4a73258f9a12580f615937bf425","src\/Notifications\/UserResetPasswordRequestNotification.php":"50a5de5d9d76e3b7c74687d7b69c8660","src\/Notifications\/UserLoginNotification.php":"b98d444c275a5dd81ca988b02c5f6ba7","src\/Notifications\/UserVerifiedNotification.php":"b6a2cabc8838bd894b8fb32118606d6a","src\/Notifications\/UserRegisteredNotification.php":"853bb60f5c70587e2c9cd0e7300f06d6","src\/Notifications\/UserLockoutNotification.php":"f02d74be244f4e21c3b14f591627c79f","src\/Traits\/BuildGenericEmail.php":"5bb5e10f82492a715a3cace242e9cb14","src\/Helpers\/TokenHelper.php":"48979b16417ba0d439a7098b4a81fa4f","src\/Http\/Controllers\/EmailTemplateController.php":"6ad4941a35bbc3144d2d9e4c5a2863d5","src\/EmailTemplatesFacade.php":"b6b04b23d3bce0ef20dab85bb7bc5a10","src\/EmailTemplates.php":"97042a283775026268c450b7deecacec","src\/Resources\/EmailTemplateResource\/Pages\/CreateEmailTemplate.php":"33c696e1aaba8d38b93f204ea63b3994","src\/Resources\/EmailTemplateResource\/Pages\/EditEmailTemplate.php":"daa6683e1dcc0d3a138a37516a3afb64","src\/Resources\/EmailTemplateResource\/Pages\/PreviewEmailTemplate.php":"a81f4bdfec107f9d407219dc67444c86","src\/Resources\/EmailTemplateResource\/Pages\/ListEmailTemplates.php":"e24886338fab775dad38495e7b0986dd","src\/Resources\/EmailTemplateResource.php":"d2d893bd56b60e0b4fb6e85b8a1fdcfa","src\/Contracts\/TokenHelperInterface.php":"abde3efddf3c32765a95912bca424b7e","src\/EmailTemplatesAuthServiceProvider.php":"3c25a71676aa2690bfac0e1659ed6374","tests\/TestCase.php":"f6ba91847024b037444f7c877794ae93","tests\/migrations\/create_email_templates_table.php":"95e3a38f1a7a360e7af2a46d54c7c460","tests\/migrations\/create_users_table.php":"a32112307e67b99b284af7038656af62","tests\/Pest.php":"b13737ea8aab41b228111a9702e70e94","tests\/Models\/User.php":"972aff9c0adb682d0e22bba4b7914492","tests\/ExampleTest.php":"9c85d3fc3571920ba5e59e6d460c5220","tests\/factories\/EmailTemplateFactory.php":"79137d76f9b6fa23981c8c1d304989cc","tests\/ResourcesTest.php":"ee435659fede5808fba7094d17e6aa32"}}
4 changes: 2 additions & 2 deletions src/Components/Iframe.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Visualbuilder\EmailTemplates\Components;

use Filament\Forms\Components\Component;
use Illuminate\Support\Str;

class Iframe extends Component
{
Expand All @@ -30,7 +29,8 @@ protected function setUp(): void
});
}

public static function make($name, $label = null, $src = null, $height = '800px', $width = '100%') {
public static function make($name, $label = null, $src = null, $height = '800px', $width = '100%')
{
return new static($name, $label, $src, $height, $width);
}
}
4 changes: 2 additions & 2 deletions src/Components/SelectLanguage.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
class SelectLanguage extends Field
{
use HasOptions;

protected string $view = 'vb-email-templates::forms.components.select-language';

}
2 changes: 1 addition & 1 deletion src/Contracts/TokenHelperInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
interface TokenHelperInterface
{
public function replaceTokens($string, $model);
}
}
13 changes: 4 additions & 9 deletions src/EmailTemplatesAuthServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,12 @@
namespace Visualbuilder\EmailTemplates;

use App\Models\User;
use Illuminate\Auth\Events\Login;
use Illuminate\Auth\Events\Registered;
use Illuminate\Auth\Notifications\VerifyEmail;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
use Visualbuilder\EmailTemplates\Listeners\UserLoginListener;
use Visualbuilder\EmailTemplates\Listeners\UserRegisteredListener;
use Visualbuilder\EmailTemplates\Mail\UserVerifyEmail;

class EmailTemplatesAuthServiceProvider extends ServiceProvider
{

/**
* Register any other events for your application.
*
Expand All @@ -22,13 +17,13 @@ class EmailTemplatesAuthServiceProvider extends ServiceProvider
public function boot()
{
parent::boot();
if(config('email-templates.send_emails.verification')){

if(config('email-templates.send_emails.verification')) {
//Override default Laravel VerifyEmail notification toMail function
VerifyEmail::toMailUsing(function (User $user, string $verificationUrl) {
return (new UserVerifyEmail($user , $verificationUrl ));
return (new UserVerifyEmail($user, $verificationUrl));
});
}

}
}
}
23 changes: 11 additions & 12 deletions src/EmailTemplatesEventServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@

namespace Visualbuilder\EmailTemplates;

use Illuminate\Auth\Events\Registered;
use Illuminate\Auth\Events\Lockout;
use Illuminate\Auth\Events\Login;
use Illuminate\Auth\Events\PasswordReset;
use Illuminate\Auth\Events\Lockout;
use Illuminate\Auth\Events\Registered;
use Illuminate\Auth\Events\Verified;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use Visualbuilder\EmailTemplates\Listeners\PasswordResetListener;
use Visualbuilder\EmailTemplates\Listeners\UserLockoutListener;
use Visualbuilder\EmailTemplates\Listeners\UserLoginListener;
use Visualbuilder\EmailTemplates\Listeners\UserRegisteredListener;
use Visualbuilder\EmailTemplates\Listeners\UserVerifiedListener;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;


class EmailTemplatesEventServiceProvider extends ServiceProvider
{
Expand All @@ -24,22 +23,22 @@ class EmailTemplatesEventServiceProvider extends ServiceProvider
*/
protected $listen = [
Login::class => [
UserLoginListener::class
UserLoginListener::class,
],
Registered::class => [
UserRegisteredListener::class,
],
PasswordReset::class => [
PasswordResetListener::class
PasswordResetListener::class,
],
Lockout::class => [
UserLockoutListener::class
UserLockoutListener::class,
],
Verified::class => [
UserVerifiedListener::class
]
UserVerifiedListener::class,
],
];

/**
* Register any other events for your application.
*
Expand All @@ -48,7 +47,7 @@ class EmailTemplatesEventServiceProvider extends ServiceProvider
public function boot()
{
parent::boot();

//
}
}
}
40 changes: 20 additions & 20 deletions src/EmailTemplatesServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,16 @@
namespace Visualbuilder\EmailTemplates;

use Filament\PluginServiceProvider;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Request;
use Illuminate\Support\Facades\Route;
use Spatie\LaravelPackageTools\Commands\InstallCommand;
use Spatie\LaravelPackageTools\Package;
use Illuminate\Support\Facades\Route;
use Visualbuilder\EmailTemplates\Contracts\TokenHelperInterface;
use Visualbuilder\EmailTemplates\Helpers\TokenHelper;
use Visualbuilder\EmailTemplates\Http\Controllers\EmailTemplateController;
use Visualbuilder\EmailTemplates\Resources\EmailTemplateResource;

class EmailTemplatesServiceProvider extends PluginServiceProvider
{

protected array $resources = [
EmailTemplateResource::class,
];
Expand All @@ -24,33 +21,36 @@ class EmailTemplatesServiceProvider extends PluginServiceProvider
'vb-email-templates-styles' => 'https://cdn.jsdelivr.net/gh/lipis/flag-icons@6.6.6/css/flag-icons.min.css',
];

public function configurePackage(Package $package): void {
public function configurePackage(Package $package): void
{
$package->name("filament-email-templates")
->hasMigrations(['create_email_templates_table'])
->hasConfigFile(['email-templates', 'filament-tiptap-editor'])
->hasAssets()
->hasViews('vb-email-templates')
->runsMigrations()
->hasInstallCommand(function(InstallCommand $command) {
$command->startWith(function(InstallCommand $command) {
$command->info('Installing Email Templates');
})->publishConfigFile()
->publishAssets()
->publishMigrations()
->askToRunMigrations()
->endWith(function(InstallCommand $command) {
$command->info('All Done');
});
});
->hasInstallCommand(function (InstallCommand $command) {
$command->startWith(function (InstallCommand $command) {
$command->info('Installing Email Templates');
})->publishConfigFile()
->publishAssets()
->publishMigrations()
->askToRunMigrations()
->endWith(function (InstallCommand $command) {
$command->info('All Done');
});
});
}

public function register() {
public function register()
{
parent::register();
$this->app->singleton(TokenHelperInterface::class, TokenHelper::class);
$this->app->register(EmailTemplatesEventServiceProvider::class);
}

public function boot() {
public function boot()
{
parent::boot();
if($this->app->runningInConsole()) {
$this->publishResources();
Expand All @@ -61,7 +61,8 @@ public function boot() {
$this->loadTranslationsFrom(__DIR__.'/../resources/lang', 'vb-email-templates');
}

protected function publishResources() {
protected function publishResources()
{
$this->publishes([
__DIR__
.'/../database/seeders/EmailTemplateSeeder.php' => database_path('seeders/EmailTemplateSeeder.php'),
Expand All @@ -85,5 +86,4 @@ public function registerRoutes()
{
Route::get('/admin/email-templates/{record}/preview', [EmailTemplateController::class, 'preview'])->name('email-template.preview');
}

}
14 changes: 7 additions & 7 deletions src/Helpers/TokenHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public function replaceTokens($content, $models)
{
// Replace singular tokens.
// These are for password reset and email verification
if(isset($models->tokens)){
if(isset($models->tokens)) {
if (isset($models->tokens->tokenUrl)) {
$content = str_replace('##tokenURL##', $models->tokens->tokenUrl, $content);
}
Expand Down Expand Up @@ -54,7 +54,7 @@ public function replaceTokens($content, $models)
}
}

$button = self::buildEmailButton($content);
$button = self::buildEmailButton($content);
$content = self::replaceButtonToken($content, $button);

return $content;
Expand All @@ -72,23 +72,23 @@ public static function buildEmailButton($content)
}
if ($check1 && $check2) {
return View::make('vb-email-templates::email.parts._button', [
'url' => $url,
'title' => $title
'url' => $url,
'title' => $title,
])
->render();
}
};

return '';
}

public static function replaceButtonToken($content, $button)
{
$search = "/(?<=##button).*?(?=##)/";
$search = "/(?<=##button).*?(?=##)/";
$replace = "";
$content = preg_replace($search, $replace, $content);
$content = str_replace('##button##', $button, $content);

return $content;
}


}
16 changes: 8 additions & 8 deletions src/Http/Controllers/EmailTemplateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,30 @@

namespace Visualbuilder\EmailTemplates\Http\Controllers;

use App\Helpers\TokenHelper;
use Illuminate\Routing\Controller;
use Visualbuilder\EmailTemplates\Contracts\TokenHelperInterface;
use Visualbuilder\EmailTemplates\Models\EmailTemplate;

class EmailTemplateController extends Controller

{
public function preview($record, TokenHelperInterface $tokenHelper) {
public function preview($record, TokenHelperInterface $tokenHelper)
{

$emailTemplate = EmailTemplate::findOrFail($record);

$model = $emailTemplate->getEmailPreviewData();

$data = [
'user' => $model->user,
'content' => $tokenHelper->replaceTokens($emailTemplate->content, $model),
'subject' => $tokenHelper->replaceTokens($emailTemplate->subject, $model),
'user' => $model->user,
'content' => $tokenHelper->replaceTokens($emailTemplate->content, $model),
'subject' => $tokenHelper->replaceTokens($emailTemplate->subject, $model),
'preHeaderText' => $tokenHelper->replaceTokens($emailTemplate->preheader, $model),
'title' => $tokenHelper->replaceTokens($emailTemplate->title, $model)
'title' => $tokenHelper->replaceTokens($emailTemplate->title, $model),
];

return view(
$emailTemplate->view_path, ['data' => $data]
$emailTemplate->view_path,
['data' => $data]
);
}
}
6 changes: 2 additions & 4 deletions src/Listeners/PasswordResetListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
namespace Visualbuilder\EmailTemplates\Listeners;

use Illuminate\Auth\Events\PasswordReset;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;

use Visualbuilder\EmailTemplates\Notifications\UserVerifiedNotification;

Expand All @@ -29,8 +27,8 @@ public function __construct()
public function handle(PasswordReset $event)
{
$user = $event->user;
$user->notify(new UserVerifiedNotification());
$user->notify(new UserVerifiedNotification());



}
}
6 changes: 2 additions & 4 deletions src/Listeners/UserLockoutListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
namespace Visualbuilder\EmailTemplates\Listeners;

use Illuminate\Auth\Events\Login;
use Visualbuilder\EmailTemplates\Notifications\UserLoginNotification;

class UserLockoutListener
{

/**
* Handle the event.
*
Expand All @@ -16,8 +14,8 @@ class UserLockoutListener
*/
public function handle(Login $event)
{
$user = $event->user;
$user->notify(new UserLoNotification());
$user = $event->user;
$user->notify(new UserLoNotification());

}
}
3 changes: 2 additions & 1 deletion src/Listeners/UserLoginListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ class UserLoginListener
*
* @return void
*/
public function handle(Login $event) {
public function handle(Login $event)
{
$user = $event->user;
$user->notify(new UserLoginNotification());
}
Expand Down
3 changes: 1 addition & 2 deletions src/Listeners/UserRegisteredListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

class UserRegisteredListener
{

/**
* Handle the event.
*
Expand All @@ -16,7 +15,7 @@ class UserRegisteredListener
*/
public function handle(Registered $event)
{
if(config('email-templates.send_emails.new_user_registered')){
if(config('email-templates.send_emails.new_user_registered')) {
$user = $event->user;
$user->notify(new UserLoginNotification());
}
Expand Down
Loading

0 comments on commit 96c0067

Please sign in to comment.