| 1 |
<?php |
| 2 |
|
| 3 |
namespace Boxzilla; |
| 4 |
|
| 5 |
use Boxzilla\Admin\Admin; |
| 6 |
use Boxzilla\Admin\Notices; |
| 7 |
use Boxzilla\DI\Container; |
| 8 |
use Boxzilla\DI\ServiceProviderInterface; |
| 9 |
|
| 10 |
class BoxzillaServiceProvider implements ServiceProviderInterface { |
| 11 |
|
| 12 |
/** |
| 13 |
* Registers services on the given container. |
| 14 |
* |
| 15 |
* This method should only be used to configure services and parameters. |
| 16 |
* It should not get services. |
| 17 |
* |
| 18 |
* @param Container $container An Container instance |
| 19 |
*/ |
| 20 |
public function register( Container $container ) { |
| 21 |
|
| 22 |
$container['admin'] = function( $container ) { |
| 23 |
return new Admin( $container->plugin, $container ); |
| 24 |
}; |
| 25 |
|
| 26 |
$container['bootstrapper'] = new Bootstrapper(); |
| 27 |
|
| 28 |
$container['box_loader'] = function( $container ) { |
| 29 |
return new BoxLoader( $container->plugin, $container->options ); |
| 30 |
}; |
| 31 |
|
| 32 |
$container['filter.autocomplete'] = function( $container ) { |
| 33 |
return new Filter\Autocomplete(); |
| 34 |
}; |
| 35 |
|
| 36 |
$container['notices'] = function( $container ) { |
| 37 |
return new Notices(); |
| 38 |
}; |
| 39 |
|
| 40 |
$container['options'] = function( $container ) { |
| 41 |
$defaults = array( |
| 42 |
'test_mode' => 0 |
| 43 |
); |
| 44 |
|
| 45 |
$options = (array) get_option( 'boxzilla_settings', $defaults ); |
| 46 |
$options = array_merge( $defaults, $options ); |
| 47 |
return $options; |
| 48 |
}; |
| 49 |
|
| 50 |
$container['plugin'] = new Plugin( |
| 51 |
'boxzilla', |
| 52 |
'Boxzilla', |
| 53 |
BOXZILLA_VERSION, |
| 54 |
BOXZILLA_FILE, |
| 55 |
dirname( BOXZILLA_FILE ) |
| 56 |
); |
| 57 |
|
| 58 |
$container['plugins'] = function( $container ) { |
| 59 |
$plugins = (array) apply_filters( 'boxzilla_extensions', array() ); |
| 60 |
return new Collection( $plugins ); |
| 61 |
}; |
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
} |
| 69 |
} |