Skip to content

Commit 5b88197

Browse files
authored
Create Runtime.php
1 parent dcd7bbc commit 5b88197

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

src/frdl/Runtime.php

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
3+
namespace frdl{
4+
5+
class Runtime
6+
{
7+
protected static $mutex = null;
8+
protected $obj = null;
9+
protected function __construct(){
10+
$this->obj = \frdl\create(function () { // function-constructor
11+
$this->container = null; // add property
12+
$this->kernel = null;
13+
$this->getContainer = function (bool $load = true) { // add method
14+
if(true === $load && null===$this->container){
15+
$this->container = new \frdl\ContainerCollection();
16+
}
17+
return $this->container;
18+
};
19+
});
20+
21+
22+
$this->obj->prototype = \frdl\create([
23+
'addContainer' => function (\Psr\Container\ContainerInterface $container) {
24+
return $this->getContainer()->addContainer($container);
25+
},
26+
'setKernel' => function (\frdlweb\AppInterface $kernel) {
27+
$this->kernel = $kernel;
28+
return $this;
29+
},
30+
'getKernel' => function (bool $load = true) : \frdlweb\AppInterface {
31+
if(true === $load && null === $this->kernel){
32+
$this->setKernel( \Webfan\Webfat\App\Kernel::mutex() );
33+
}
34+
return $this->kernel;
35+
},
36+
]);
37+
38+
//$this->obj = $this->obj();
39+
}
40+
41+
public function getObject(){
42+
return $this->obj;
43+
}
44+
45+
public static function global(){
46+
if(null === self::$mutex){
47+
$class = \get_called_class();
48+
self::$mutex = new $class();
49+
}
50+
return self::$mutex->getObject();
51+
}
52+
}
53+
54+
55+
}

0 commit comments

Comments
 (0)