1
1
MONARC Core project
2
2
===================
3
3
4
- See example repository for create:
5
-
6
- * Entity
7
- * Table
8
- * Service
9
- * Controller
10
- * and configure Module.php & module.config.php
11
-
12
- Entity
13
- ------
14
-
15
- Create Entity file & class in Model/Entity folder and extend it whith ` AbstractEntity ` .
16
-
17
- Define ` protected ` attributes and use [ DoctrineOrm] [ 1 ] for define table & columns.
18
-
19
- In ` Module.php:getServiceConfig() ` add in ` invokables ` :
20
-
21
- '\Monarc\Core\Model\Entity\MyEntity' => '\Monarc\Core\Model\Entity\MyEntity',
22
-
23
- For generating migrating file & migrate DB avec adding/deleting/changing column:
24
-
25
- php ./vendor/bin/doctrine-module migrations:diff
26
- php ./vendor/bin/doctrine-module migrations:migrate
27
-
28
-
29
- Entity Table
30
- ------------
31
-
32
- Create EntityTable file & class in Model/Table folder and extend it whith ` AbstractEntityTable ` .
33
-
34
- Define your own functions fo loading entities datas from database.
35
- AbstractEntityTable has already functions:
36
-
37
- * getDb: return DB object
38
- * fetchAll: return all data for entity
39
- * get: return entity
40
- * save
41
- * delete
42
-
43
- In ` Module.php:getServiceConfig() ` add in ` factories ` :
44
-
45
- '\Monarc\Core\Model\Table\MyEntityTable' => function($sm){
46
- return new Model\Table\MyEntityTable($sm->get('\Monarc\Core\Model\Db'));
47
- },
48
-
49
-
50
- Controller
51
- ----------
52
-
53
- Create Controller file & class in Controller folder and extend it with ` AbstractController ` .
54
-
55
- Adding function:
56
-
57
- * getList()
58
- * get($id)
59
- * create($data)
60
- * update($id, $data)
61
- * delete($id)
62
-
63
- In ` module.config.php ` , define route & controller:
64
-
65
- 'controller' => '\Monarc\Core\Controller\MyIndex',
66
-
67
-
68
- Controller Factory
69
- ------------------
70
-
71
- Create Controller Factory file & class in Controller folder and extend it with ` AbstractControllerFactory ` .
72
-
73
- Define ` protected $serviceName = '\Monarc\Core\Service\MyService'; ` .
74
-
75
- In ` Module.php:getControllerConfig() ` add in ` factories ` :
76
-
77
- '\Monarc\Core\Controller\MyIndex' => '\Monarc\Core\Controller\MyIndexControllerFactory',
78
-
79
-
80
- Service
81
- -------
82
-
83
- Create Service file & class in Service folder and extend it with ` AbstractService ` .
84
-
85
- Define attributes ressources used in this service:
86
-
87
- protected $ressource1;
88
- protected $ressource2;
89
-
90
- And business functions.
91
-
92
- For accessing ressource:
93
-
94
- $this->get('ressource1');
95
-
96
- Or
97
-
98
- $this->getServiceFactory();
99
-
100
-
101
- Service Factory
102
- ---------------
103
-
104
- Create Service file & class in Service Factory folder and extend it with ` AbstractServiceFactory ` .
105
-
106
- Define ressources to load in Service:
107
-
108
- protected $ressources = array(
109
- 'ressource1'=> '\Monarc\Core\Model\Table\EntityTable',
110
- 'ressource2'=> '\Monarc\Core\Model\Entity\Entity',
111
- );
112
-
113
- Or
114
-
115
- protected $ressources = '\Monarc\Core\Model\Table\EntityTable';
116
-
117
- In ` Module.php:getServiceConfig() ` add in ` factories ` :
118
-
119
- '\Monarc\Core\Service\MyIndexService' => '\Monarc\Core\Service\MyIndexServiceFactory',
120
-
121
-
122
-
123
4
License
124
5
-------
125
6
126
7
This software is licensed under
127
8
[ GNU Affero General Public License version 3] ( http://www.gnu.org/licenses/agpl-3.0.html )
128
9
129
- - Copyright (C) 2016-2018 Jérôme Lombardi - https://github.com/jerolomb
130
- - Copyright (C) 2016-2018 Juan Rocha - https://github.com/jfrocha
131
- - Copyright (C) 2016-2018 SMILE gie securitymadein.lu
132
- - Copyright (C) 2017-2018 Cédric Bonhomme - https://github.com/cedricbonhomme
10
+ - Copyright (C) 2022-2024 Luxembourg House of Cybersecurity https://lhc.lu
11
+ - Copyright (C) 2016-2022 SMILE gie securitymadein.lu
12
+ - Copyright (C) 2016-2024 Jérôme Lombardi - https://github.com/jerolomb
13
+ - Copyright (C) 2016-2024 Juan Rocha - https://github.com/jfrocha
14
+ - Copyright (C) 2017-2024 Cédric Bonhomme - https://www.cedricbonhomme.org
15
+ - Copyright (C) 2019-2024 Ruslan Baidan - https://github.com/ruslanbaidan
133
16
- Copyright (C) 2016-2017 Guillaume Lesniak
134
17
- Copyright (C) 2016-2017 Thomas Metois
135
18
- Copyright (C) 2016-2017 Jérôme De Almeida
@@ -140,11 +23,3 @@ Disclaimer: This program is distributed in the hope that it will be useful, but
140
23
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
141
24
FITNESS FOR A PARTICULAR PURPOSE.
142
25
See the GNU Affero General Public License for more details.
143
-
144
-
145
-
146
- [ ^ 1 ] : https://stevenwilliamalexander.wordpress.com/2013/09/25/zf2-restful-api-example/
147
- [ ^ 2 ] : https://www.youtube.com/watch?v=CGEDNMzWoFk
148
- [ ^ 3 ] : http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/basic-mapping.html
149
-
150
- [ 1 ] : http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/basic-mapping.html
0 commit comments