| 1 |
<?php |
| 2 |
|
| 3 |
namespace FL\Assistant\System; |
| 4 |
|
| 5 |
use FL\Assistant\Providers\CloudServiceProvider; |
| 6 |
use FL\Assistant\Providers\DataServiceProvider; |
| 7 |
use FL\Assistant\Providers\HooksServiceProvider; |
| 8 |
use FL\Assistant\Providers\RestServiceProvider; |
| 9 |
use FL\Assistant\Providers\ViewServiceProvider; |
| 10 |
use FL\Assistant\System\Util\PhpVersionCheck; |
| 11 |
use FL\Assistant\Providers\PostTypeServiceProvider; |
| 12 |
|
| 13 |
// Alias the injector - its our DI container. |
| 14 |
use FL\Assistant\System\Container\Injector as Container; |
| 15 |
use FL\Assistant\System\Util\Psr4Autoloader; |
| 16 |
|
| 17 |
/** |
| 18 |
* Class Plugin |
| 19 |
* @package FL\Assistant\Core |
| 20 |
*/ |
| 21 |
class Plugin { |
| 22 |
|
| 23 |
/** |
| 24 |
* @var Container |
| 25 |
*/ |
| 26 |
protected $container; |
| 27 |
|
| 28 |
/** |
| 29 |
* Providers are registered in the order they are listed here |
| 30 |
* @var array |
| 31 |
*/ |
| 32 |
public $providers = [ |
| 33 |
ViewServiceProvider::class, |
| 34 |
DataServiceProvider::class, |
| 35 |
PostTypeServiceProvider::class, |
| 36 |
HooksServiceProvider::class, |
| 37 |
RestServiceProvider::class, |
| 38 |
CloudServiceProvider::class, |
| 39 |
]; |
| 40 |
|
| 41 |
/** |
| 42 |
* Plugin constructor. |
| 43 |
* |
| 44 |
* @param $pluginFile |
| 45 |
* |
| 46 |
* @throws \FL\Assistant\System\Container\InjectionException |
| 47 |
*/ |
| 48 |
public function __construct( $plugin_file ) { |
| 49 |
$this->check_minimum_php_requirements(); |
| 50 |
|
| 51 |
$this->register_providers(); |
| 52 |
|
| 53 |
// notify assistant was loaded |
| 54 |
do_action( 'fl_assistant_loaded' ); |
| 55 |
|
| 56 |
// compatibility with SG Optimizer plugin |
| 57 |
add_filter( 'sgo_js_minify_exclude', [ $this, 'js_minify_exclude' ] ); |
| 58 |
} |
| 59 |
|
| 60 |
/** |
| 61 |
* exclude js if minify javaScript files setting is enabled |
| 62 |
*/ |
| 63 |
public function js_minify_exclude( $js_list ) { |
| 64 |
$js_list[] = 'fl-assistant'; |
| 65 |
$js_list[] = 'fl-assistant-apps'; |
| 66 |
return $js_list; |
| 67 |
} |
| 68 |
|
| 69 |
/** |
| 70 |
* |
| 71 |
*/ |
| 72 |
public function check_minimum_php_requirements() { |
| 73 |
$php_version_check = new PhpVersionCheck(); |
| 74 |
$php_version_check->check(); |
| 75 |
} |
| 76 |
|
| 77 |
public function register_providers() { |
| 78 |
$this->container = new Container(); |
| 79 |
foreach ( $this->providers as $provider_class ) { |
| 80 |
$provider = $this->container->make( $provider_class, [ $this->container ] ); |
| 81 |
$this->container->execute( [ $provider, 'bootstrap' ] ); |
| 82 |
} |
| 83 |
} |
| 84 |
|
| 85 |
} |
| 86 |
|
| 87 |
|