FundCommand.php
5 years ago
FundFactory.php
5 years ago
FundRepository.php
5 years ago
ServiceProvider.php
5 years ago
ServiceProvider.php
41 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\TestData\Addons\Funds; |
| 4 | |
| 5 | use WP_CLI; |
| 6 | use Give\ServiceProviders\ServiceProvider as GiveServiceProvider; |
| 7 | |
| 8 | /** |
| 9 | * Class ServiceProvider |
| 10 | * @package Give\TestData\Funds |
| 11 | */ |
| 12 | class ServiceProvider implements GiveServiceProvider { |
| 13 | /** |
| 14 | * @inheritDoc |
| 15 | */ |
| 16 | public function register() { |
| 17 | } |
| 18 | |
| 19 | /** |
| 20 | * @inheritDoc |
| 21 | */ |
| 22 | public function boot() { |
| 23 | // Add CLI commands |
| 24 | if ( defined( 'WP_CLI' ) && WP_CLI ) { |
| 25 | WP_CLI::add_command( 'give test-funds', give()->make( FundCommand::class ) ); |
| 26 | } |
| 27 | |
| 28 | /** |
| 29 | * Inject Fund ID into revenue data |
| 30 | */ |
| 31 | add_filter( |
| 32 | 'give-test-data-revenue-definition', |
| 33 | function ( $args ) { |
| 34 | $args['fund_id'] = give( FundFactory::class )->getRandomFund(); |
| 35 | |
| 36 | return $args; |
| 37 | } |
| 38 | ); |
| 39 | } |
| 40 | } |
| 41 |