woocommerce-paypal-payments/woocommerce-paypal-commerce-gateway.php

86 lines
2.5 KiB
PHP
Raw Normal View History

2020-03-19 16:47:08 +01:00
<?php # -*- coding: utf-8 -*-
declare( strict_types = 1 );
/**
* Plugin Name: WooCommerce PayPal Commerce Gateway
* Plugin URI: TODO
* Description: PayPal Commerce Platform for WooCommerce
* Version: dev-master
* Author: Inpsyde GmbH
* Author URI: https://inpsyde.com/
* License: GPL-2.0
* Text Domain: woocommerce-paypal-commerce-gateway
* Domain Path: /languages
* Network: TODO: Specify value 'true' or remove line
*/
2020-06-15 11:48:37 +03:00
2020-03-19 16:47:08 +01:00
namespace Inpsyde\PayPalCommerce;
2020-04-02 08:38:00 +03:00
use Dhii\Container\CachingContainer;
use Dhii\Container\CompositeCachingServiceProvider;
use Dhii\Container\DelegatingContainer;
use Dhii\Container\ProxyContainer;
use Dhii\Modular\Module\ModuleInterface;
2020-04-06 10:51:56 +03:00
use Inpsyde\PayPalCommerce\ApiClient\Factory\PurchaseUnitFactory;
2020-04-02 08:38:00 +03:00
(function () {
2020-07-01 08:05:24 +03:00
/**
* ToDo: Check if we always need autoloader. This is a current
* workaround because of the wpcust setup
**/
include_once __DIR__.'/vendor/autoload.php';
2020-04-02 08:38:00 +03:00
function init()
{
static $initialized;
if (!$initialized) {
2020-04-28 15:03:39 +03:00
$modules = [new PluginModule()];
2020-04-02 08:38:00 +03:00
foreach (glob(plugin_dir_path(__FILE__).'modules/*/module.php') as $moduleFile) {
$modules[] = (@require $moduleFile)();
}
2020-06-15 11:48:37 +03:00
foreach (glob(plugin_dir_path(__FILE__).'modules.local/*/module.php') as $moduleFile) {
$modules[] = (@require $moduleFile)();
}
2020-04-02 08:38:00 +03:00
$providers = [];
foreach ($modules as $module) {
/* @var $module ModuleInterface */
$providers[] = $module->setup();
}
$proxy = new ProxyContainer();
$provider = new CompositeCachingServiceProvider($providers);
$container = new CachingContainer(new DelegatingContainer($provider));
$proxy->setInnerContainer($container);
foreach ($modules as $module) {
/* @var $module ModuleInterface */
$module->run($container);
}
$initialized = true;
2020-04-06 10:51:56 +03:00
2020-04-02 08:38:00 +03:00
}
}
add_action(
'plugins_loaded',
function () {
init();
}
);
register_activation_hook(
__FILE__,
function () {
init();
do_action('woocommerce-paypal-commerce-gateway.activate');
}
);
register_deactivation_hook(
__FILE__,
function () {
init();
do_action('woocommerce-paypal-commerce-gateway.deactivate');
}
);
2020-04-06 10:51:56 +03:00
2020-04-02 08:38:00 +03:00
})();