Container.php
2 years ago
FeatureProviderInterface.php
4 years ago
FeatureServiceProvider.php
4 years ago
Resolver.php
2 years ago
ServiceProvider.php
3 years ago
Resolver.php
27 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WPStaging\Framework\DI; |
| 4 | |
| 5 | use WPStaging\Framework\Interfaces\ShutdownableInterface; |
| 6 | use WPStaging\Vendor\lucatume\DI52\Builders\Resolver as BaseResolver; |
| 7 | |
| 8 | class Resolver extends BaseResolver |
| 9 | { |
| 10 | /** |
| 11 | * Allows to enqueue the ShutdownableInterface hook |
| 12 | * on classes resolved by the DI container, such as |
| 13 | * dependencies injected in the __construct. |
| 14 | */ |
| 15 | public function resolve($id, array $buildLine = null) |
| 16 | { |
| 17 | $instance = parent::resolve($id, $buildLine); |
| 18 | if (is_object($instance) && $instance instanceof ShutdownableInterface) { |
| 19 | if (!has_action('shutdown', [$instance, 'onWpShutdown'])) { |
| 20 | add_action('shutdown', [$instance, 'onWpShutdown']); |
| 21 | } |
| 22 | } |
| 23 | |
| 24 | return $instance; |
| 25 | } |
| 26 | } |
| 27 |