-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCurrentServiceContainer.php
More file actions
92 lines (73 loc) · 1.82 KB
/
CurrentServiceContainer.php
File metadata and controls
92 lines (73 loc) · 1.82 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
namespace WebFace;
use FormBuilder;
use \Silex\Application;
use WebFace\Entity\Entity;
use WebFace\Entity\EntityManager;
use WebFace\ListControl\FilterBuilder;
use WebFace\ListControl\ListBuilder;
class CurrentServiceContainer
{
/** @var \Silex\Application */
protected $app;
/** @var string|null Name of the table */
protected $currentTable = null;
public function __construct(Application $app)
{
$this->app = $app;
}
public function setCurrentTable($currentTable)
{
$this->currentTable = $currentTable;
}
public function getCurrentTable()
{
return $this->currentTable;
}
public function checkCurrentTable()
{
if ($this->currentTable === null) {
throw new CurrentServiceNotSetException();
}
}
/**
* @return ListBuilder
*/
public function getListBuilder()
{
$this->checkCurrentTable();
return $this->app['webface.' . $this->currentTable . '.list.builder'];
}
/**
* @return FilterBuilder
*/
public function getFilterBuilder()
{
$this->checkCurrentTable();
return $this->app['webface.' . $this->currentTable . '.list.filter'];
}
/**
* @return EntityManager
*/
public function getEntityManager()
{
$this->checkCurrentTable();
return $this->app['webface.' . $this->currentTable . '.entity.manager'];
}
/**
* @return Entity
*/
public function getEntity()
{
$this->checkCurrentTable();
return $this->app['webface.' . $this->currentTable . '.entity'];
}
/**
* @return FormBuilder
*/
public function getFormBuilder()
{
$this->checkCurrentTable();
return $this->app['webface.' . $this->currentTable . '.form.builder'];
}
}