-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'trunk' into bug/fix-project-configuration
- Loading branch information
Showing
23 changed files
with
719 additions
and
352 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
/** | ||
* Bootstraps the modular app. | ||
* | ||
* @package WooCommerce\PayPalCommerce | ||
*/ | ||
|
||
use Dhii\Container\CachingContainer; | ||
use Dhii\Container\CompositeCachingServiceProvider; | ||
use Dhii\Container\CompositeContainer; | ||
use Dhii\Container\DelegatingContainer; | ||
use Dhii\Container\ProxyContainer; | ||
use Dhii\Modular\Module\ModuleInterface; | ||
use Interop\Container\ServiceProviderInterface; | ||
use Psr\Container\ContainerInterface; | ||
|
||
return function ( | ||
string $root_dir, | ||
ContainerInterface ...$additional_containers | ||
): ContainerInterface { | ||
$modules = ( require "$root_dir/modules.php" )( $root_dir ); | ||
|
||
// Use this filter to add custom module or remove some of existing ones. | ||
// Modules able to access container, add services and modify existing ones. | ||
$modules = apply_filters( 'woocommerce_paypal_payments_modules', $modules ); | ||
|
||
$providers = array_map( | ||
function ( ModuleInterface $module ): ServiceProviderInterface { | ||
return $module->setup(); | ||
}, | ||
$modules | ||
); | ||
|
||
$provider = new CompositeCachingServiceProvider( $providers ); | ||
$proxy_container = new ProxyContainer(); | ||
// TODO: caching does not work currently, | ||
// may want to consider fixing it later (pass proxy as parent to DelegatingContainer) | ||
// for now not fixed since we were using this behavior for long time and fixing it now may break things. | ||
$container = new DelegatingContainer( $provider ); | ||
$app_container = new CachingContainer( | ||
new CompositeContainer( | ||
array_merge( | ||
$additional_containers, | ||
array( $container ) | ||
) | ||
) | ||
); | ||
$proxy_container->setInnerContainer( $app_container ); | ||
|
||
foreach ( $modules as $module ) { | ||
/* @var $module ModuleInterface module */ | ||
$module->run( $app_container ); | ||
} | ||
|
||
return $app_container; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
/** | ||
* The list of modules. | ||
* | ||
* @package WooCommerce\PayPalCommerce | ||
*/ | ||
|
||
use WooCommerce\PayPalCommerce\PluginModule; | ||
|
||
return function ( string $root_dir ): iterable { | ||
$modules_dir = "$root_dir/modules"; | ||
|
||
$modules = array( | ||
new PluginModule(), | ||
( require "$modules_dir/woocommerce-logging/module.php" )(), | ||
( require "$modules_dir/ppcp-admin-notices/module.php" )(), | ||
( require "$modules_dir/ppcp-api-client/module.php" )(), | ||
( require "$modules_dir/ppcp-button/module.php" )(), | ||
( require "$modules_dir/ppcp-compat/module.php" )(), | ||
( require "$modules_dir/ppcp-onboarding/module.php" )(), | ||
( require "$modules_dir/ppcp-session/module.php" )(), | ||
( require "$modules_dir/ppcp-status-report/module.php" )(), | ||
( require "$modules_dir/ppcp-subscription/module.php" )(), | ||
( require "$modules_dir/ppcp-wc-gateway/module.php" )(), | ||
( require "$modules_dir/ppcp-webhooks/module.php" )(), | ||
); | ||
|
||
return $modules; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.