| 1 |
<?php |
| 2 |
/** |
| 3 |
* Transactions: Service provider |
| 4 |
* |
| 5 |
* @package SimplePay |
| 6 |
* @subpackage Core |
| 7 |
* @copyright Copyright (c) 2022, Sandhills Development, LLC |
| 8 |
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
| 9 |
* @since 4.4.6 |
| 10 |
*/ |
| 11 |
|
| 12 |
namespace SimplePay\Core\Transaction; |
| 13 |
|
| 14 |
use SimplePay\Core\AbstractPluginServiceProvider; |
| 15 |
use SimplePay\Vendor\League\Container\ServiceProvider\BootableServiceProviderInterface; |
| 16 |
|
| 17 |
/** |
| 18 |
* TransactionsServiceProvider class. |
| 19 |
* |
| 20 |
* @since 4.4.6 |
| 21 |
*/ |
| 22 |
class TransactionServiceProvider extends AbstractPluginServiceProvider implements BootableServiceProviderInterface { |
| 23 |
|
| 24 |
/** |
| 25 |
* {@inheritdoc} |
| 26 |
*/ |
| 27 |
public function get_services() { |
| 28 |
return array( |
| 29 |
'transaction-repository', |
| 30 |
); |
| 31 |
} |
| 32 |
|
| 33 |
/** |
| 34 |
* {@inheritdoc} |
| 35 |
*/ |
| 36 |
public function get_subscribers() { |
| 37 |
return array( |
| 38 |
'transaction-observer', |
| 39 |
); |
| 40 |
} |
| 41 |
|
| 42 |
/** |
| 43 |
* {@inheritdoc} |
| 44 |
*/ |
| 45 |
public function boot() { |
| 46 |
$container = $this->getContainer(); |
| 47 |
|
| 48 |
// Install repository table. |
| 49 |
// Create the table with BerlinDB. |
| 50 |
// Call maybe_upgrade() immediately instead of waiting for admin_init. |
| 51 |
$table = new Database\Table; |
| 52 |
$table->maybe_upgrade(); |
| 53 |
|
| 54 |
// Repository. |
| 55 |
$container->share( |
| 56 |
'transaction-repository', |
| 57 |
TransactionRepository::class |
| 58 |
); |
| 59 |
} |
| 60 |
|
| 61 |
/** |
| 62 |
* {@inheritdoc} |
| 63 |
*/ |
| 64 |
public function register() { |
| 65 |
$container = $this->getContainer(); |
| 66 |
|
| 67 |
// Observer. |
| 68 |
$container->share( |
| 69 |
'transaction-observer', |
| 70 |
TransactionObserver::class |
| 71 |
) |
| 72 |
->withArgument( $container->get( 'transaction-repository' ) ) |
| 73 |
->withArgument( $container->get( 'stripe-connect-application-fee' ) ); |
| 74 |
} |
| 75 |
|
| 76 |
} |
| 77 |
|