File tree Expand file tree Collapse file tree 3 files changed +18
-8
lines changed
Expand file tree Collapse file tree 3 files changed +18
-8
lines changed Original file line number Diff line number Diff line change 44
55$ builder = new ContainerBuilder ();
66
7+ $ builder = apply_filters ('starter_kit/container_builder ' , $ builder );
8+
79$ builder ->addDefinitions (require __DIR__ . '/dependencies.php ' );
810
911return $ builder ->build ();
Original file line number Diff line number Diff line change 77 */
88abstract class AbstractSingleton
99{
10+ /**
11+ * Array of instances of singleton classes
12+ *
13+ * @var array
14+ */
15+ private static array $ instances = [];
16+
1017 /**
1118 * Call this method to get singleton
1219 */
13- public static function instance (): bool | static
20+ public static function instance (): static
1421 {
15- static $ instance = false ;
16- if ($ instance === false ) {
17- $ instance = new static ();
22+ $ class = static ::class;
23+
24+ if (!isset (self ::$ instances [$ class ])) {
25+ self ::$ instances [$ class ] = new static ();
1826 }
1927
20- return $ instance ;
28+ return self :: $ instances [ $ class ] ;
2129 }
2230
2331 /**
Original file line number Diff line number Diff line change 44
55defined ('ABSPATH ' ) || exit;
66
7+ use Psr \Container \ContainerInterface ;
8+ use Psr \Log \LoggerInterface ;
79use StarterKit \Base \Constants ;
810use StarterKit \Base \Hooks ;
9- use StarterKit \Handlers \CLI \CLI ;
1011use StarterKit \Error \ErrorHandler ;
11- use Psr \Container \ContainerInterface ;
12- use Psr \Log \LoggerInterface ;
12+ use StarterKit \Handlers \CLI \CLI ;
1313use Throwable ;
1414
1515/**
You can’t perform that action at this time.
0 commit comments