monarc / backoffice
Backoffice for monarc/monarc-backoffice application
Requires
- php: ^7.4 || ^8.0
- ext-json: *
- ext-pdo: *
- doctrine/doctrine-orm-module: ^5.1
- laminas/laminas-dependency-plugin: ^2.0
- laminas/laminas-di: ^3.1
- laminas/laminas-mvc: ^3.1
- laminas/laminas-permissions-rbac: ^3.0
- monarc/core: ^2.12.6
- robmorgan/phinx: ^0.13.4
Requires (Dev)
- roave/security-advisories: dev-latest
This package is auto-updated.
Last update: 2023-06-01 15:38:22 UTC
README
See example repository for create:
- Entity
- Entity Table
- Controller
- Controller Factory
- Service
- Service Factory
- and configure Module.php & module.config.php
Entity
Create Entity file & class in Model/Entity folder and extend it whith AbstractEntity
.
Define protected
attributes and use DoctrineOrm for define table & columns.
In Module.php:getServiceConfig()
add in invokables
:
'\Monarc\Core\Model\Entity\MyEntity' => '\Monarc\Core\Model\Entity\MyEntity',
For generating migrating file & migrate DB avec adding/deleting/changing column:
php ./vendor/bin/doctrine-module migrations:diff
php ./vendor/bin/doctrine-module migrations:migrate
Entity Table
Create EntityTable file & class in Model/Table folder and extend it whith AbstractEntityTable
.
Define your own functions fo loading entities datas from database. AbstractEntityTable has already functions:
- getDb: return DB object
- fetchAll: return all data for entity
- get: return entity
- save
- delete
In Module.php:getServiceConfig()
add in factories
:
'\Monarc\Core\Model\Table\MyEntityTable' => function($sm){
return new Model\Table\MyEntityTable($sm->get('\Monarc\Core\Model\Db'));
},
Controller
Create Controller file & class in Controller folder and extend it with AbstractController
.
Adding function:
- getList()
- get($id)
- create($data)
- update($id, $data)
- delete($id)
In module.config.php
, define route & controller:
'controller' => '\Monarc\Core\Controller\MyIndex',
Controller Factory
Create Controller Factory file & class in Controller folder and extend it with AbstractControllerFactory
.
Define protected $serviceName = '\Monarc\Core\Service\MyService';
.
In Module.php:getControllerConfig()
add in factories
:
'\Monarc\Core\Controller\MyIndex' => '\Monarc\Core\Controller\MyIndexControllerFactory',
Service
Create Service file & class in Service folder and extend it with AbstractService
.
Define attributes ressources used in this service:
protected $ressource1;
protected $ressource2;
And business functions.
For accessing ressource:
$this->get('ressource1');
Or
$this->getServiceFactory();
Service Factory
Create Service file & class in Service Factory folder and extend it with AbstractServiceFactory
.
Define ressources to load in Service:
protected $ressources = array(
'ressource1'=> '\Monarc\Core\Model\Table\EntityTable',
'ressource2'=> '\Monarc\Core\Model\Entity\Entity',
);
Or
protected $ressources = '\Monarc\Core\Model\Table\EntityTable';
In Module.php:getServiceConfig()
add in factories
:
'\Monarc\Core\Service\MyIndexService' => '\Monarc\Core\Service\MyIndexServiceFactory',
License
This software is licensed under GNU Affero General Public License version 3
- Copyright (C) 2016-2018 Jérôme Lombardi - https://github.com/jerolomb
- Copyright (C) 2016-2018 Juan Rocha - https://github.com/jfrocha
- Copyright (C) 2016-2018 SMILE gie securitymadein.lu
- Copyright (C) 2017-2018 Cédric Bonhomme - https://github.com/cedricbonhomme
- Copyright (C) 2016-2017 Guillaume Lesniak
- Copyright (C) 2016-2017 Thomas Metois
- Copyright (C) 2016-2017 Jérôme De Almeida
For more information, the list of authors and contributors is available.
Disclaimer: This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.