| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace WPDesk\FlexibleSubscriptions\Compatibility; |
| 6 |
|
| 7 |
use WPDesk\FlexibleSubscriptions\Vendor\Psr\Container\ContainerInterface; |
| 8 |
use WPDesk\FlexibleSubscriptions\Vendor\WPDesk\Init\Plugin\Plugin; |
| 9 |
|
| 10 |
class CompatibilityLoader { |
| 11 |
|
| 12 |
private Plugin $plugin; |
| 13 |
|
| 14 |
private ContainerInterface $container; |
| 15 |
|
| 16 |
public function __construct( Plugin $plugin, ContainerInterface $container ) { |
| 17 |
$this->plugin = $plugin; |
| 18 |
$this->container = $container; |
| 19 |
} |
| 20 |
|
| 21 |
public function load( string $plugin ): void { |
| 22 |
if ( $plugin === 'woocommerce-subscriptions' ) { |
| 23 |
$compat_path = $this->plugin->get_path( "/compat/$plugin/index.php" ); |
| 24 |
if ( file_exists( $compat_path ) ) { |
| 25 |
$__fsb_compatibility_container = $this->container; |
| 26 |
require_once $compat_path; |
| 27 |
} |
| 28 |
return; |
| 29 |
} |
| 30 |
|
| 31 |
throw new \RuntimeException( "Couldn't find compatibility layer for $plugin" ); |
| 32 |
} |
| 33 |
} |
| 34 |
|