PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 3.6.0
GiveWP – Donation Plugin and Fundraising Platform v3.6.0
4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 2.31.0 2.31.1 All 253 releases
give / src / DonationForms / Controllers / DonationFormViewController.php

DonationFormViewController.php in GiveWP – Donation Plugin and Fundraising Platform 3.6.0, at src/DonationForms/Controllers/DonationFormViewController.php

53 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Give\DonationForms\Controllers;
4
5 use Give\DonationForms\DataTransferObjects\DonationFormPreviewRouteData;
6 use Give\DonationForms\DataTransferObjects\DonationFormViewRouteData;
7 use Give\DonationForms\Models\DonationForm;
8 use Give\DonationForms\ViewModels\DonationFormViewModel;
9
10 class DonationFormViewController
11 {
12 /**
13 * This renders the donation form view.
14 *
15 * @since 3.0.0
16 */
17 public function show(DonationFormViewRouteData $data): string
18 {
19 /** @var DonationForm $donationForm */
20 $donationForm = DonationForm::find($data->formId);
21
22 $viewModel = new DonationFormViewModel(
23 $donationForm->id,
24 $donationForm->blocks,
25 $donationForm->settings
26 );
27
28 ob_clean();
29 return $viewModel->render();
30 }
31
32 /**
33 * This renders the donation form preview
34 *
35 * @since 3.0.0
36 */
37 public function preview(DonationFormPreviewRouteData $data): string
38 {
39 /** @var DonationForm $donationForm */
40 $donationForm = DonationForm::find($data->formId);
41
42 $viewModel = new DonationFormViewModel(
43 $donationForm->id,
44 $data->formBlocks ?: $donationForm->blocks,
45 $data->formSettings ?: $donationForm->settings,
46 true
47 );
48
49 ob_clean();
50 return $viewModel->render();
51 }
52 }
53