| 1 |
<?php |
| 2 |
/** |
| 3 |
* A global service locator for the plugin. |
| 4 |
* |
| 5 |
* @since 0.1.0 |
| 6 |
* |
| 7 |
* @deprecated We really should not use a service locator. |
| 8 |
* |
| 9 |
* @package SolidWP\Performance |
| 10 |
*/ |
| 11 |
|
| 12 |
namespace SolidWP\Performance; |
| 13 |
|
| 14 |
use SolidWP\Performance\lucatume\DI52\App as DI52App; |
| 15 |
use SolidWP\Performance\StellarWP\ContainerContract\ContainerInterface; |
| 16 |
|
| 17 |
if ( ! defined( 'ABSPATH' ) ) { |
| 18 |
exit; |
| 19 |
} |
| 20 |
|
| 21 |
/** |
| 22 |
* Provides a global facade for easy access to the container. |
| 23 |
* |
| 24 |
* @deprecated We really should not use a service locator. |
| 25 |
* |
| 26 |
* @since 0.1.0 |
| 27 |
* |
| 28 |
* @package SolidWP\Performance |
| 29 |
*/ |
| 30 |
class App extends DI52App { |
| 31 |
|
| 32 |
/** |
| 33 |
* A reference to the singleton instance of the DI container |
| 34 |
* the application uses as Service Locator. |
| 35 |
* |
| 36 |
* @since 0.1.0 |
| 37 |
* |
| 38 |
* @var ContainerInterface |
| 39 |
* |
| 40 |
* @phpstan-ignore-next-line |
| 41 |
*/ |
| 42 |
protected static $container; |
| 43 |
|
| 44 |
|
| 45 |
/** |
| 46 |
* Sets the container instance the Application should use as a Service Locator. |
| 47 |
* |
| 48 |
* If the Application already stores a reference to a Container instance, then |
| 49 |
* this will be replaced by the new one. |
| 50 |
* |
| 51 |
* @since 0.1.0 |
| 52 |
* |
| 53 |
* @param ContainerInterface $container A reference to the Container instance the Application |
| 54 |
* should use as a Service Locator. |
| 55 |
* |
| 56 |
* @return void The method does not return any value. |
| 57 |
*/ |
| 58 |
public static function setContainer( $container ) { |
| 59 |
static::$container = $container; |
| 60 |
} |
| 61 |
|
| 62 |
/** |
| 63 |
* Returns the singleton instance of the DI container the application |
| 64 |
* will use as Service Locator. |
| 65 |
* |
| 66 |
* @since 0.1.0 |
| 67 |
* |
| 68 |
* @return ContainerInterface The singleton instance of the Container used as Service Locator |
| 69 |
* by the application. |
| 70 |
*/ |
| 71 |
public static function container() { |
| 72 |
return static::$container; |
| 73 |
} |
| 74 |
} |
| 75 |
|