DonationFormRepository.php
5 years ago
DonationRepository.php
5 years ago
DonorRepository.php
5 years ago
RevenueRepository.php
5 years ago
RevenueRepository.php
45 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\TestData\Repositories; |
| 4 | |
| 5 | use Give\TestData\Factories\RevenueFactory as RevenueFactory; |
| 6 | |
| 7 | /** |
| 8 | * Class RevenueRepository |
| 9 | * @package GiveTestData\TestData\Repositories |
| 10 | */ |
| 11 | class RevenueRepository { |
| 12 | /** |
| 13 | * @var RevenueFactory |
| 14 | */ |
| 15 | private $revenueFactory; |
| 16 | |
| 17 | /** |
| 18 | * @param RevenueFactory $revenueFactory |
| 19 | */ |
| 20 | public function __construct( RevenueFactory $revenueFactory ) { |
| 21 | $this->revenueFactory = $revenueFactory; |
| 22 | } |
| 23 | |
| 24 | |
| 25 | /** |
| 26 | * Insert revenue |
| 27 | * |
| 28 | * @param array $revenue |
| 29 | * |
| 30 | * @since 1.0.0 |
| 31 | */ |
| 32 | public function insertRevenue( $revenue ) { |
| 33 | global $wpdb; |
| 34 | |
| 35 | $revenue = wp_parse_args( |
| 36 | apply_filters( 'give-test-data-revenue-definition', $revenue ), |
| 37 | $this->revenueFactory->definition() |
| 38 | ); |
| 39 | |
| 40 | $wpdb->insert( "{$wpdb->prefix}give_revenue", $revenue ); |
| 41 | |
| 42 | do_action( 'give-test-data-insert-revenue', $wpdb->insert_id, $revenue ); |
| 43 | } |
| 44 | } |
| 45 |