-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pass data to email channel and store double-opt-in main data in mail …
…params, resolves #479
- Loading branch information
Showing
8 changed files
with
147 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
src/MailEditor/Widget/DoubleOptInSessionAdditionalDataWidget.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
namespace FormBuilderBundle\MailEditor\Widget; | ||
|
||
use FormBuilderBundle\MailEditor\AttributeBag; | ||
use FormBuilderBundle\MailEditor\Widget\MailEditorWidgetInterface; | ||
use FormBuilderBundle\Model\DoubleOptInSessionInterface; | ||
|
||
class DoubleOptInSessionAdditionalDataWidget implements MailEditorWidgetInterface | ||
{ | ||
public function getWidgetGroupName(): string | ||
{ | ||
return 'form_builder.mail_editor.widget_provider.double_opt_in_session'; | ||
} | ||
|
||
public function getWidgetLabel(): string | ||
{ | ||
return 'form_builder.mail_editor.widget_provider.double_opt_in_session.additional_data'; | ||
} | ||
|
||
public function getWidgetConfig(): array | ||
{ | ||
return [ | ||
'field' => [ | ||
'type' => 'input', | ||
'defaultValue' => null, | ||
'label' => 'form_builder.mail_editor.widget_provider.double_opt_in_session.additional_data_field' | ||
], | ||
]; | ||
} | ||
|
||
public function getValueForOutput(AttributeBag $attributeBag, string $layoutType): string | ||
{ | ||
$rawOutputData = $attributeBag->get('raw_output_data', []); | ||
|
||
if (!array_key_exists('double_opt_in_session', $rawOutputData)) { | ||
return '[NO VALUE]'; | ||
} | ||
|
||
$doubleOptInSession = $rawOutputData['double_opt_in_session']; | ||
if (!is_array($doubleOptInSession)) { | ||
return '[NO VALUE]'; | ||
} | ||
|
||
$field = $attributeBag->get('field', null); | ||
$additionalData = $doubleOptInSession['additional_data']; | ||
|
||
if (!array_key_exists($field, $additionalData)) { | ||
return '[NO VALUE]'; | ||
} | ||
|
||
return (string) $additionalData[$field]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
namespace FormBuilderBundle\MailEditor\Widget; | ||
|
||
use FormBuilderBundle\MailEditor\AttributeBag; | ||
use FormBuilderBundle\Model\DoubleOptInSessionInterface; | ||
|
||
class DoubleOptInSessionEmailWidget implements MailEditorWidgetInterface | ||
{ | ||
public function getWidgetGroupName(): string | ||
{ | ||
return 'form_builder.mail_editor.widget_provider.double_opt_in_session'; | ||
} | ||
|
||
public function getWidgetLabel(): string | ||
{ | ||
return 'form_builder.mail_editor.widget_provider.double_opt_in_session.email'; | ||
} | ||
|
||
public function getWidgetConfig(): array | ||
{ | ||
return []; | ||
} | ||
|
||
public function getValueForOutput(AttributeBag $attributeBag, string $layoutType): string | ||
{ | ||
$rawOutputData = $attributeBag->get('raw_output_data', []); | ||
|
||
if (!array_key_exists('double_opt_in_session', $rawOutputData)) { | ||
return '[NO VALUE]'; | ||
} | ||
|
||
$doubleOptInSession = $rawOutputData['double_opt_in_session']; | ||
if (!is_array($doubleOptInSession)) { | ||
return '[NO VALUE]'; | ||
} | ||
|
||
$email = $doubleOptInSession['email'] ?? null; | ||
if ($email === null) { | ||
return '[NO VALUE]'; | ||
} | ||
|
||
return $email; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters