-
-
Notifications
You must be signed in to change notification settings - Fork 548
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[4.x] Allow using Global Set variables in form email configs (#8892)
Co-authored-by: duncanmcclean <[email protected]> Co-authored-by: Jason Varga <[email protected]>
- Loading branch information
1 parent
89bd9d5
commit b3e634f
Showing
2 changed files
with
30 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
use Mockery; | ||
use Statamic\Facades\Blueprint; | ||
use Statamic\Facades\Form; | ||
use Statamic\Facades\GlobalSet; | ||
use Statamic\Facades\Site; | ||
use Statamic\Forms\Email; | ||
use Statamic\Forms\Submission; | ||
|
@@ -92,6 +93,12 @@ public function singleAddressProvider() | |
'single email with name using antlers' => ['{{ name }} <{{ email }}>', [ | ||
['address' => '[email protected]', 'name' => 'Foo Bar'], | ||
]], | ||
'single email from global set using antlers' => ['{{ company_information:email }}', [ | ||
['address' => '[email protected]', 'name' => null], | ||
]], | ||
'single email with name from global set using antlers' => ['{{ company_information:name }} <{{ company_information:email }}>', [ | ||
['address' => '[email protected]', 'name' => 'Example Company'], | ||
]], | ||
]; | ||
} | ||
|
||
|
@@ -190,12 +197,28 @@ private function makeEmailWithSubmission(Submission $submission) | |
|
||
private function makeEmailWithConfig(array $config) | ||
{ | ||
$globalSet = GlobalSet::make()->handle('company_information'); | ||
$globalSet->addLocalization($globalSet->makeLocalization('en')->data([ | ||
'name' => 'Example Company', | ||
'email' => '[email protected]', | ||
])); | ||
$globalSet->save(); | ||
|
||
$formBlueprint = Blueprint::makeFromFields([ | ||
'name' => ['type' => 'text'], | ||
'email' => ['type' => 'text'], | ||
]); | ||
|
||
$companyInformationBlueprint = Blueprint::makeFromFields([ | ||
'name' => ['type' => 'text'], | ||
'email' => ['type' => 'text'], | ||
]); | ||
|
||
BlueprintRepository::shouldReceive('find')->with('forms.test')->andReturn($formBlueprint); | ||
BlueprintRepository::shouldReceive('find')->with('globals.company_information')->andReturn($companyInformationBlueprint); | ||
|
||
$form = tap(Form::make('test'))->save(); | ||
|
||
$submission = $form->makeSubmission()->data([ | ||
'name' => 'Foo Bar', | ||
'email' => '[email protected]', | ||
|