| 1 |
<?php |
| 2 |
|
| 3 |
namespace Give\DonationForms\Blocks\DonationFormBlock\DataTransferObjects; |
| 4 |
|
| 5 |
use Give\Framework\Support\Contracts\Arrayable; |
| 6 |
|
| 7 |
class BlockAttributes implements Arrayable |
| 8 |
{ |
| 9 |
/** |
| 10 |
* @var int|null |
| 11 |
*/ |
| 12 |
public $formId; |
| 13 |
/** |
| 14 |
* @var string |
| 15 |
*/ |
| 16 |
public $blockId; |
| 17 |
|
| 18 |
/** |
| 19 |
* @var string |
| 20 |
*/ |
| 21 |
public $formFormat; |
| 22 |
|
| 23 |
/** |
| 24 |
* @var string |
| 25 |
*/ |
| 26 |
public $openFormButton; |
| 27 |
|
| 28 |
/** |
| 29 |
* @since 3.2.2 add v3 default for form button. |
| 30 |
* @since 3.0.0 |
| 31 |
*/ |
| 32 |
public static function fromArray(array $array): BlockAttributes |
| 33 |
{ |
| 34 |
$self = new self(); |
| 35 |
|
| 36 |
$self->formId = !empty($array['formId']) ? (int)$array['formId'] : null; |
| 37 |
$self->blockId = !empty($array['blockId']) ? (string)$array['blockId'] : null; |
| 38 |
$self->formFormat = !empty($array['formFormat']) ? (string)$array['formFormat'] : null; |
| 39 |
$self->openFormButton = !empty($array['openFormButton']) ? (string)$array['openFormButton'] : __('Donate now', 'give'); |
| 40 |
|
| 41 |
return $self; |
| 42 |
} |
| 43 |
|
| 44 |
/** |
| 45 |
* @since 3.0.0 |
| 46 |
*/ |
| 47 |
public function toArray(): array |
| 48 |
{ |
| 49 |
return get_object_vars($this); |
| 50 |
} |
| 51 |
} |
| 52 |
|