-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsystem.php
More file actions
53 lines (41 loc) · 1.04 KB
/
system.php
File metadata and controls
53 lines (41 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
use DI\ContainerBuilder;
final class System {
/**
* * @var \DI\Container
*/
protected $container;
/**
* @var system
*/
protected static $instance;
protected function __construct() {
$this->buildContainer();
}
public function getInstance() : system
{
if( null == static::$instance ){
static::$instance = new static();
}
return static::$instance;
}
public function getContainer() : \DI\Container
{
return $this->container;
}
/**
* @return \DI\Container
*/
protected function buildContainer() {
$builder = new ContainerBuilder();
$builder->addDefinitions( [
'RecentPosts' => function ( ContainerBuilder $c ) {
return PostsFactory::create( 'post', 3 );
},
'Products' => function ( ContainerBuilder $c ) {
return PostsFactory::create( 'product', 50 );
}
] );
$this->container = $builder->build();
}
}