Actions
1 year ago
AdminFormListView
1 year ago
FormGrid
1 year ago
resources
1 year ago
AsyncDataHelpers.php
1 year ago
AsyncDataHelpers.php
43 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\DonationForms\AsyncData; |
| 4 | |
| 5 | use Give\DonationForms\DataTransferObjects\DonationFormGoalData; |
| 6 | use Give\DonationForms\V2\Models\DonationForm; |
| 7 | use Give\MultiFormGoals\ProgressBar\Model as ProgressBarModel; |
| 8 | |
| 9 | /** |
| 10 | * @since 3.16.0 |
| 11 | */ |
| 12 | class AsyncDataHelpers |
| 13 | { |
| 14 | /** |
| 15 | * @since 3.16.0 |
| 16 | */ |
| 17 | public static function getFormDonationsCountValue($formId): int |
| 18 | { |
| 19 | return (new ProgressBarModel(['ids' => [$formId], 'statusList' => ['any']]))->getDonationCount(); |
| 20 | } |
| 21 | |
| 22 | /** |
| 23 | * @since 4.2.0 return float value |
| 24 | * @since 3.16.0 |
| 25 | */ |
| 26 | public static function getFormRevenueValue($formId): float |
| 27 | { |
| 28 | $donationForm = DonationForm::find($formId); |
| 29 | $form = $donationForm->toV3Form(); |
| 30 | $goalData = new DonationFormGoalData($form->id, $form->settings); |
| 31 | |
| 32 | return $goalData->getCurrentAmount(); |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * @since 3.16.0 |
| 37 | */ |
| 38 | public static function getSkeletonPlaceholder($width = '100%', $height = '0.7rem'): string |
| 39 | { |
| 40 | return '<span class="give-skeleton js-give-async-data" style="width: ' . esc_attr($width) . '; height: ' . esc_attr($height) . ';"></span>'; |
| 41 | } |
| 42 | } |
| 43 |