woocommerce-paypal-payments/bootstrap.php

46 lines
1.2 KiB
PHP
Raw Permalink Normal View History

2021-08-27 20:40:09 +03:00
<?php
/**
* Bootstraps the modular app.
*
* @package WooCommerce\PayPalCommerce
*/
2025-01-15 18:13:16 +04:00
namespace WooCommerce\PayPalCommerce;
2023-11-23 17:43:56 +00:00
use WooCommerce\PayPalCommerce\Vendor\Inpsyde\Modularity\Package;
use WooCommerce\PayPalCommerce\Vendor\Inpsyde\Modularity\Properties\PluginProperties;
use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface;
2021-08-27 20:40:09 +03:00
return function (
string $root_dir,
array $additional_containers = array(),
array $additional_modules = array()
2021-08-27 20:40:09 +03:00
): ContainerInterface {
2023-03-14 16:38:28 +02:00
/**
* Skip path check.
*
* @psalm-suppress UnresolvableInclude
*/
2021-08-27 20:40:09 +03:00
$modules = ( require "$root_dir/modules.php" )( $root_dir );
$modules = array_merge( $modules, $additional_modules );
/**
* Use this filter to add custom module or remove some of existing ones.
* Modules able to access container, add services and modify existing ones.
*/
2021-08-27 20:40:09 +03:00
$modules = apply_filters( 'woocommerce_paypal_payments_modules', $modules );
2023-11-23 17:43:56 +00:00
// Initialize plugin.
2025-07-04 20:18:23 +04:00
$properties = PluginProperties::new( "$root_dir/woocommerce-paypal-payments.php" );
2023-11-24 18:07:56 +00:00
$bootstrap = Package::new( $properties );
2021-08-27 20:40:09 +03:00
foreach ( $modules as $module ) {
$bootstrap->addModule( $module );
}
2023-11-23 17:43:56 +00:00
$bootstrap->boot();
return $bootstrap->container();
2021-08-27 20:40:09 +03:00
};