PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.8.1
GiveWP – Donation Plugin and Fundraising Platform v4.16.8.1
4.16.9 4.16.8.1 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 All 255 releases
give / src / TestData / Repositories / DonorRepository.php

DonorRepository.php in GiveWP – Donation Plugin and Fundraising Platform 4.16.8.1, at src/TestData/Repositories/DonorRepository.php

66 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Give\TestData\Repositories;
4
5 use Give\TestData\Factories\DonorFactory;
6 use Give\TestData\Framework\MetaRepository;
7
8 /**
9 * Class DonorRepository
10 * @package GiveTestData\TestData\Repositories
11 */
12 class DonorRepository
13 {
14 /**
15 * @var DonorFactory
16 */
17 private $donorFactory;
18
19 /**
20 * DonorRepository constructor.
21 *
22 * @param DonorFactory $donorFactory
23 */
24 public function __construct(DonorFactory $donorFactory)
25 {
26 $this->donorFactory = $donorFactory;
27 }
28
29 /**
30 * Insert Donor
31 *
32 * @since 1.0.0
33 *
34 * @param array $donor
35 *
36 */
37 public function insertDonor($donor)
38 {
39 global $wpdb;
40
41 // Insert donor
42 $wpdb->insert(
43 "{$wpdb->prefix}give_donors",
44 [
45 'email' => $donor['email'],
46 'name' => sprintf('%s %s', $donor['first_name'], $donor['last_name']),
47 'date_created' => $donor['date_created'],
48 ]
49 );
50 $donorID = $wpdb->insert_id;
51 $metaRepository = new MetaRepository('give_donormeta', 'donor_id');
52
53 $donorMeta = wp_parse_args(
54 apply_filters('give-test-data-donor-meta', $donorID, $donor),
55 [
56 '_give_donor_first_name' => $donor['first_name'],
57 '_give_donor_last_name' => $donor['last_name'],
58 ]
59 );
60
61 $metaRepository->persist($donorID, $donorMeta);
62
63 do_action('give-test-data-insert-donor', $donorID, $donor);
64 }
65 }
66