1111
1212namespace LIN3S \AdminBundle \Configuration \Model ;
1313
14- use LIN3S \AdminBundle \Repository \QueryBuilder ;
14+ use LIN3S \AdminBundle \Repository \AdminRepository ;
1515
1616/**
17- * Entity configuration.
18- *
1917 * @author Gorka Laucirica <gorka.lauzirika@gmail.com>
2018 */
2119final class Entity
2220{
23- /**
24- * Collection of actions.
25- *
26- * @var array
27- */
28- protected $ actions ;
29-
30- /**
31- * The entity name.
32- *
33- * @var string
34- */
35- protected $ name ;
36-
37- /**
38- * The class name.
39- *
40- * @var string
41- */
42- protected $ className ;
43-
44- /**
45- * The list actions.
46- *
47- * @var array
48- */
49- protected $ listActions ;
50-
51- /**
52- * The list fields.
53- *
54- * @var array
55- */
56- protected $ listFields ;
57-
58- /**
59- * The list filters.
60- *
61- * @var array
62- */
63- protected $ listFilters ;
64-
65- /**
66- * The entities per page.
67- *
68- * @var int
69- */
70- protected $ listEntitiesPerPage ;
71-
72- /**
73- * The list global actions.
74- *
75- * @var array
76- */
77- protected $ listGlobalActions ;
78-
79- /**
80- * The list order by default.
81- *
82- * @var array
83- */
84- protected $ listOrderByDefault ;
85-
86- /**
87- * The entity name, for visualization purposes.
88- *
89- * It contains the singular and plural cases.
90- *
91- * @var array
92- */
21+ private $ actions ;
22+ private $ name ;
23+ private $ className ;
24+ private $ listActions ;
25+ private $ listFields ;
26+ private $ listFilters ;
27+ private $ listEntitiesPerPage ;
28+ private $ listGlobalActions ;
29+ private $ listOrderByDefault ;
9330 private $ printNames ;
31+ private $ repositoryServiceId ;
32+ private $ repository ;
9433
95- /**
96- * The query builder.
97- *
98- * @var QueryBuilder
99- */
100- protected $ queryBuilder ;
101-
102- /**
103- * EntityConfiguration constructor.
104- *
105- * @param string $name The entity name
106- * @param string $className The class name
107- * @param array $actions Collection of actions
108- * @param array $listActions List actions
109- * @param array $listFields List fields
110- * @param array $listFilters List filters
111- * @param array $listGlobalActions List global actions
112- * @param QueryBuilder $queryBuilder The query builder
113- * @param array $printNames The entity name, for visualization purposes
114- * @param int $listEntitiesPerPage The number of entities per page
115- * @param array $listOrderByDefault The order by default
116- */
11734 public function __construct (
11835 $ name ,
11936 $ className ,
@@ -122,7 +39,7 @@ public function __construct(
12239 array $ listFields = [],
12340 array $ listFilters = [],
12441 array $ listGlobalActions = [],
125- QueryBuilder $ queryBuilder ,
42+ $ repositoryServiceId ,
12643 array $ printNames ,
12744 $ listEntitiesPerPage ,
12845 array $ listOrderByDefault = []
@@ -135,7 +52,7 @@ public function __construct(
13552 $ this ->actions = $ actions ;
13653 $ this ->listActions = $ listActions ;
13754 $ this ->listGlobalActions = $ listGlobalActions ;
138- $ this ->queryBuilder = $ queryBuilder ;
55+ $ this ->repositoryServiceId = $ repositoryServiceId ;
13956 $ this ->printNames = $ printNames ;
14057 $ this ->listEntitiesPerPage = $ listEntitiesPerPage ;
14158 $ this ->listOrderByDefault = $ listOrderByDefault ;
@@ -365,13 +282,24 @@ public function printNames()
365282 return $ this ->printNames ;
366283 }
367284
368- /**
369- * Gets the query builder.
370- *
371- * @return QueryBuilder
372- */
373- public function queryBuilder ()
285+ public function repositoryServiceId ()
286+ {
287+ return $ this ->repositoryServiceId ;
288+ }
289+
290+ public function repository ()
291+ {
292+ if (!$ this ->repository instanceof AdminRepository) {
293+ throw new \Exception (
294+ sprintf ('The repository is not loaded yet ' )
295+ );
296+ }
297+
298+ return $ this ->repository ;
299+ }
300+
301+ public function loadRepository (AdminRepository $ repository )
374302 {
375- return $ this ->queryBuilder ;
303+ $ this ->repository = $ repository ;
376304 }
377305}
0 commit comments