DateCreatedColumn.php
3 years ago
DonationCountColumn.php
8 months ago
DonationRevenueColumn.php
8 months ago
DonorInformationColumn.php
8 months ago
DonorTypeColumn.php
9 months ago
IdColumn.php
3 years ago
LatestDonationColumn.php
8 months ago
DonorInformationColumn.php
70 lines
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Give\Donors\ListTable\Columns; |
| 6 | |
| 7 | use Give\Donors\DonorsAdminPage; |
| 8 | use Give\Donors\Models\Donor; |
| 9 | use Give\Framework\ListTable\ModelColumn; |
| 10 | |
| 11 | /** |
| 12 | * @since 2.24.0 |
| 13 | * |
| 14 | * @extends ModelColumn<Donor> |
| 15 | */ |
| 16 | class DonorInformationColumn extends ModelColumn |
| 17 | { |
| 18 | |
| 19 | protected $sortColumn = ['firstName', 'lastName']; |
| 20 | |
| 21 | /** |
| 22 | * @since 2.24.0 |
| 23 | * |
| 24 | * @inheritDoc |
| 25 | */ |
| 26 | public static function getId(): string |
| 27 | { |
| 28 | return 'donorInformation'; |
| 29 | } |
| 30 | |
| 31 | /** |
| 32 | * @since 4.12.0 Update column label |
| 33 | * @since 2.24.0 |
| 34 | * |
| 35 | * @inheritDoc |
| 36 | */ |
| 37 | public function getLabel(): string |
| 38 | { |
| 39 | return __('Name', 'give'); |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * @since 4.12.0 Remove gravatar from donor information column |
| 44 | * @since 3.20.0 Use email to get avatar URL |
| 45 | * @since 2.24.0 |
| 46 | * |
| 47 | * @inheritDoc |
| 48 | * |
| 49 | * @param Donor $model |
| 50 | */ |
| 51 | public function getCellValue($model): string |
| 52 | { |
| 53 | $template = ' |
| 54 | <div class="donorInformation"> |
| 55 | <a href="%s">%s</a> |
| 56 | <span class="donorInformation__email">%s</span> |
| 57 | </div> |
| 58 | '; |
| 59 | |
| 60 | $url = DonorsAdminPage::getDetailsPageUrl($model->id); |
| 61 | |
| 62 | return sprintf( |
| 63 | $template, |
| 64 | $url, |
| 65 | trim("$model->firstName $model->lastName"), |
| 66 | $model->email |
| 67 | ); |
| 68 | } |
| 69 | } |
| 70 |