| 1 |
<?php |
| 2 |
/** |
| 3 |
* A base class all service providers should extend. |
| 4 |
* |
| 5 |
* @since 0.1.0 |
| 6 |
* |
| 7 |
* @package SolidWP\Performance |
| 8 |
*/ |
| 9 |
|
| 10 |
declare( strict_types=1 ); |
| 11 |
|
| 12 |
namespace SolidWP\Performance\Contracts; |
| 13 |
|
| 14 |
use SolidWP\Performance\Container; |
| 15 |
|
| 16 |
if ( ! defined( 'ABSPATH' ) ) { |
| 17 |
exit; |
| 18 |
} |
| 19 |
|
| 20 |
/** |
| 21 |
* A local instance to prevent coupling directly to Di52. |
| 22 |
* |
| 23 |
* @since 0.1.0 |
| 24 |
* |
| 25 |
* @package SolidWP\Performance |
| 26 |
*/ |
| 27 |
abstract class Service_Provider { |
| 28 |
|
| 29 |
/** |
| 30 |
* Whether this service provider will be a deferred one or not. |
| 31 |
* |
| 32 |
* @var bool |
| 33 |
*/ |
| 34 |
protected bool $deferred = false; |
| 35 |
|
| 36 |
/** |
| 37 |
* The container instance. |
| 38 |
* |
| 39 |
* @var Container |
| 40 |
*/ |
| 41 |
protected Container $container; |
| 42 |
|
| 43 |
/** |
| 44 |
* @param Container $container The container instance. |
| 45 |
*/ |
| 46 |
public function __construct( Container $container ) { |
| 47 |
$this->container = $container; |
| 48 |
} |
| 49 |
|
| 50 |
/** |
| 51 |
* Registers the service provider container bindings. |
| 52 |
* |
| 53 |
* @return void |
| 54 |
*/ |
| 55 |
abstract public function register(): void; |
| 56 |
|
| 57 |
/** |
| 58 |
* Whether the service provider will be a deferred one or not. |
| 59 |
* |
| 60 |
* @return bool |
| 61 |
*/ |
| 62 |
public function isDeferred(): bool { |
| 63 |
return $this->deferred; |
| 64 |
} |
| 65 |
|
| 66 |
/** |
| 67 |
* Returns an array of the class or interfaces bound and provided by the service provider. |
| 68 |
* |
| 69 |
* @return string[] A list of fully-qualified implementations provided by the service provider. |
| 70 |
*/ |
| 71 |
public function provides(): array { |
| 72 |
return []; |
| 73 |
} |
| 74 |
|
| 75 |
/** |
| 76 |
* Binds and sets up implementations at boot time. |
| 77 |
* |
| 78 |
* @return void |
| 79 |
*/ |
| 80 |
public function boot(): void { |
| 81 |
} |
| 82 |
|
| 83 |
/** |
| 84 |
* Register all action hooks for the provider. |
| 85 |
* |
| 86 |
* @since 0.1.0 |
| 87 |
* |
| 88 |
* @return void |
| 89 |
*/ |
| 90 |
public function register_actions(): void {} |
| 91 |
|
| 92 |
/** |
| 93 |
* Register all filter hooks for the provider. |
| 94 |
* |
| 95 |
* @since 0.1.0 |
| 96 |
* |
| 97 |
* @return void |
| 98 |
*/ |
| 99 |
public function register_filters(): void {} |
| 100 |
} |
| 101 |
|