AbstractDependencyType.php
2 years ago
Container.php
2 years ago
FactoryType.php
2 years ago
SharedType.php
2 years ago
SharedType.php
33 lines
| 1 | <?php |
| 2 | namespace Automattic\WooCommerce\Blocks\Registry; |
| 3 | |
| 4 | /** |
| 5 | * A definition for the SharedType dependency type. |
| 6 | * |
| 7 | * @since 2.5.0 |
| 8 | */ |
| 9 | class SharedType extends AbstractDependencyType { |
| 10 | |
| 11 | /** |
| 12 | * Holds a cached instance of the value stored (or returned) internally. |
| 13 | * |
| 14 | * @var mixed |
| 15 | */ |
| 16 | private $shared_instance; |
| 17 | |
| 18 | /** |
| 19 | * Returns the internal stored and shared value after initial generation. |
| 20 | * |
| 21 | * @param Container $container An instance of the dependency injection |
| 22 | * container. |
| 23 | * |
| 24 | * @return mixed |
| 25 | */ |
| 26 | public function get( Container $container ) { |
| 27 | if ( empty( $this->shared_instance ) ) { |
| 28 | $this->shared_instance = $this->resolve_value( $container ); |
| 29 | } |
| 30 | return $this->shared_instance; |
| 31 | } |
| 32 | } |
| 33 |