PluginProbe ʕ •ᴥ•ʔ
Pods – Custom Content Types and Fields / 3.2.2
Pods – Custom Content Types and Fields v3.2.2
trunk 1.14.8 2.7.31.3 2.8.23.3 2.9.19.3 3.0.10.3 3.1.4.1 3.2.0 3.2.1 3.2.1.1 3.2.2 3.2.4 3.2.5 3.2.6 3.2.7 3.2.7.1 3.2.8 3.2.8.1 3.2.8.2 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9
pods / src / Pods / Container / Container_DI52.php
pods / src / Pods / Container Last commit date
Container_DI52.php 2 years ago Container_Interface.php 2 years ago
Container_DI52.php
95 lines
1 <?php
2
3 namespace Pods\Container;
4
5 use Pods\Prefixed\lucatume\DI52\Container as DI52Container;
6
7 /**
8 * Describes the interface of a container that exposes methods to read its entries.
9 *
10 * @credit The StellarWP team - https://github.com/stellarwp/container-contract
11 *
12 * @since 3.0
13 *
14 * @method mixed getVar( string $key, mixed|null $default = null )
15 * @method void register( string $serviceProviderClass, string ...$alias )
16 * @method self when( string $class )
17 * @method self needs( string $id )
18 * @method void give( mixed $implementation )
19 */
20 class Container_DI52 implements Container_Interface {
21
22 /**
23 * @var self
24 */
25 protected static $instance;
26
27 /**
28 * @var DI52Container
29 */
30 protected $container;
31
32 /**
33 * Container constructor.
34 *
35 * @param object $container The container to use.
36 */
37 public function __construct( $container = null ) {
38 $this->container = $container ?: new DI52Container();
39 }
40
41 /**
42 * @return self
43 */
44 public static function init() {
45 if ( empty( self::$instance ) ) {
46 self::$instance = new self();
47 }
48
49 return self::$instance;
50 }
51
52 /**
53 * @inheritDoc
54 */
55 public function bind( string $id, $implementation = null, array $afterBuildMethods = null ) {
56 $this->container->bind( $id, $implementation, $afterBuildMethods );
57 }
58
59 /**
60 * @inheritDoc
61 */
62 public function get( string $id ) {
63 return $this->container->get( $id );
64 }
65
66 /**
67 * @return DI52Container
68 */
69 public function get_container() {
70 return $this->container;
71 }
72
73 /**
74 * @inheritDoc
75 */
76 public function has( string $id ) {
77 return $this->container->has( $id );
78 }
79
80 /**
81 * @inheritDoc
82 */
83 public function singleton( string $id, $implementation = null, array $afterBuildMethods = null ) {
84 $this->container->singleton( $id, $implementation, $afterBuildMethods );
85 }
86
87 /**
88 * Defer all other calls to the container object.
89 */
90 #[\ReturnTypeWillChange]
91 public function __call( $name, $arguments ) {
92 return $this->container->{$name}( ...$arguments );
93 }
94 }
95