| 1 |
<?php |
| 2 |
|
| 3 |
namespace Give\Campaigns\Actions; |
| 4 |
|
| 5 |
use Give\Campaigns\Models\Campaign; |
| 6 |
use Give\Campaigns\ValueObjects\CampaignGoalType; |
| 7 |
use Give\Campaigns\ValueObjects\CampaignStatus; |
| 8 |
use Give\Campaigns\ValueObjects\CampaignType; |
| 9 |
use Give\Framework\Support\Facades\DateTime\Temporal; |
| 10 |
|
| 11 |
/** |
| 12 |
* @since 4.0.0 |
| 13 |
*/ |
| 14 |
class ConvertQueryDataToCampaign |
| 15 |
{ |
| 16 |
/** |
| 17 |
* @since 4.0.0 |
| 18 |
*/ |
| 19 |
public function __invoke(object $queryObject): Campaign |
| 20 |
{ |
| 21 |
return new Campaign([ |
| 22 |
'id' => (int)$queryObject->id, |
| 23 |
'pageId' => $queryObject->pageId ? (int)$queryObject->pageId : null, |
| 24 |
'defaultFormId' => $queryObject->defaultFormId ? (int)$queryObject->defaultFormId : null, |
| 25 |
'type' => new CampaignType($queryObject->type), |
| 26 |
'title' => $queryObject->title, |
| 27 |
'shortDescription' => $queryObject->shortDescription, |
| 28 |
'longDescription' => $queryObject->longDescription, |
| 29 |
'logo' => $queryObject->logo, |
| 30 |
'image' => $queryObject->image, |
| 31 |
'primaryColor' => $queryObject->primaryColor, |
| 32 |
'secondaryColor' => $queryObject->secondaryColor, |
| 33 |
'goal' => (int)$queryObject->goal, |
| 34 |
'goalType' => new CampaignGoalType($queryObject->goalType), |
| 35 |
'startDate' => $queryObject->startDate ? Temporal::toDateTime($queryObject->startDate) : null, |
| 36 |
'endDate' => $queryObject->endDate ? Temporal::toDateTime($queryObject->endDate) : null, |
| 37 |
'status' => new CampaignStatus($queryObject->status), |
| 38 |
'createdAt' => Temporal::toDateTime($queryObject->createdAt), |
| 39 |
]); |
| 40 |
} |
| 41 |
} |
| 42 |
|