22
33namespace Symbiotic \Develop \Debug \Packages ;
44
5- use Symbiotic \Core \CoreInterface ;
5+ use Psr \Container \ContainerInterface ;
6+ use Symbiotic \Container \CloningContainer ;
67use Symbiotic \Develop \Services \Debug \Timer ;
78use Symbiotic \Packages \PackageConfig ;
89use Symbiotic \Packages \PackagesLoaderInterface ;
910use Symbiotic \Packages \PackagesRepositoryInterface ;
10- use function _S \core ;
1111
12- class PackagesRepository implements PackagesRepositoryInterface
13- {
14-
15- /**
16- * @var PackagesRepositoryInterface
17- */
18- protected $ object ;
1912
20- /**
21- * @var Timer
22- */
23- protected $ timer ;
13+ class PackagesRepository implements PackagesRepositoryInterface, CloningContainer
14+ {
2415
2516
26- public function __construct (PackagesRepositoryInterface $ packages )
27- {
28- $ this ->object = $ packages ;
17+ public function __construct (
18+ protected PackagesRepositoryInterface $ object ,
19+ protected ContainerInterface $ container
20+ ) {
2921 }
3022
3123 public function load (): void
3224 {
33- core (Timer::class)->start ('load_packages ' );
25+ $ this -> container -> get (Timer::class)->start ('load_packages ' );
3426 $ this ->call (__FUNCTION__ , func_get_args ());
35- core (Timer::class)->end ('load_packages ' );
27+ $ this -> container -> get (Timer::class)->end ('load_packages ' );
3628 }
3729
3830 public function has ($ id ): bool
@@ -45,16 +37,16 @@ public function get(string $id): array
4537 return $ this ->call (__FUNCTION__ , func_get_args ());
4638 }
4739
48- public function getPackageConfig (string $ id ):?PackageConfig
40+ public function getPackageConfig (string $ id ): ?PackageConfig
4941 {
5042 return $ this ->call (__FUNCTION__ , func_get_args ());
5143 }
5244
5345 public function getIds (): array
5446 {
55- $ name = core (Timer::class)->start ();
47+ $ name = $ this -> container -> get (Timer::class)->start ();
5648 $ data = $ this ->call (__FUNCTION__ , func_get_args ());
57- core (Timer::class)->end ($ name );
49+ $ this -> container -> get (Timer::class)->end ($ name );
5850 return $ data ;
5951 }
6052
@@ -71,9 +63,9 @@ public function getEventsHandlers(): array
7163
7264 public function all (): array
7365 {
74- $ name = core (Timer::class)->start ();
66+ $ name = $ this -> container -> get (Timer::class)->start ();
7567 $ data = $ this ->call (__FUNCTION__ , func_get_args ());
76- core (Timer::class)->end ($ name );
68+ $ this -> container -> get (Timer::class)->end ($ name );
7769 return $ data ;
7870 }
7971
@@ -92,4 +84,13 @@ protected function call($method, $parameters)
9284 return call_user_func_array ([$ this ->object , $ method ], $ parameters );
9385 }
9486
87+ public function cloneInstance (?ContainerInterface $ container ): ?object
88+ {
89+ $ this ->container = $ container ;
90+ if ($ this ->object instanceof CloningContainer) {
91+ $ this ->object = $ this ->object ->cloneInstance ($ container );
92+ }
93+ return null ;
94+ }
95+
9596}
0 commit comments