PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.1.0
GiveWP – Donation Plugin and Fundraising Platform v4.1.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 / DataTransferObjects / DonationFormQueryData.php

DonationFormQueryData.php in GiveWP – Donation Plugin and Fundraising Platform 4.1.0, at src/DonationForms/DataTransferObjects/DonationFormQueryData.php

84 lines 1.8 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\DataTransferObjects;
4
5 use DateTimeInterface;
6 use Give\DonationForms\Models\DonationForm;
7 use Give\DonationForms\ValueObjects\DonationFormMetaKeys;
8 use Give\DonationForms\ValueObjects\DonationFormStatus;
9 use Give\Framework\Blocks\BlockCollection;
10 use Give\Framework\Support\Facades\DateTime\Temporal;
11
12 class DonationFormQueryData
13 {
14 /**
15 * @var int
16 */
17 public $id;
18
19 /**
20 * @var string
21 */
22 public $title;
23
24 /**
25 * @var array
26 */
27 public $settings;
28
29 /**
30 * @var DateTimeInterface
31 */
32 public $createdAt;
33
34 /**
35 * @var DateTimeInterface
36 */
37 public $updatedAt;
38
39 /**
40 * @var DonationFormStatus
41 */
42 public $status;
43
44 /**
45 * @var BlockCollection
46 */
47 public $blocks;
48
49 /**
50 * Convert data from object to Donation Form
51 *
52 * @since 3.0.0
53 *
54 * @param object $queryObject
55 *
56 * @return DonationFormQueryData
57 */
58 public static function fromObject($queryObject): self
59 {
60 $self = new self();
61 $self->id = (int)$queryObject->id;
62 $self->title = $queryObject->title;
63 $self->createdAt = Temporal::toDateTime($queryObject->createdAt);
64 $self->updatedAt = Temporal::toDateTime($queryObject->updatedAt);
65 $self->status = new DonationFormStatus($queryObject->status);
66 $self->settings = json_decode($queryObject->{DonationFormMetaKeys::SETTINGS()->getKeyAsCamelCase()}, true);
67 $self->blocks = BlockCollection::fromJson($queryObject->blocks);
68
69 return $self;
70 }
71
72 /**
73 * Convert DTO to Donation Form
74 *
75 * @return DonationForm
76 */
77 public function toDonationForm(): DonationForm
78 {
79 $attributes = get_object_vars($this);
80
81 return new DonationForm($attributes);
82 }
83 }
84