From 2ac6ea9110a9afe7c62cf19b3e00fc6881057e4f Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sun, 22 Dec 2019 16:47:56 +0100 Subject: [PATCH] update --- application/sample.md | 2 +- basics/dispatching.md | 4 +- components/modules.md | 78 +++++++++++++++++++++++++++++++++ components/packages.md | 27 +++++++++++- datastorage/database/queries.md | 36 ++++++++++++++- setup/installation.md | 2 +- standards/documentation.md | 2 +- 7 files changed, 144 insertions(+), 7 deletions(-) diff --git a/application/sample.md b/application/sample.md index fa93542..15e457d 100644 --- a/application/sample.md +++ b/application/sample.md @@ -212,7 +212,7 @@ use app\view\TestView; class TestController { - private ApplicationAbstract $app = null; + private ApplicationAbstract $app; /* the dispatcher passes the ApplicationAbstract reference to the controller */ public function __construct(ApplicationAbstract $app) diff --git a/basics/dispatching.md b/basics/dispatching.md index 6375eb4..c199186 100644 --- a/basics/dispatching.md +++ b/basics/dispatching.md @@ -41,11 +41,11 @@ $dispatcher->dispatch(function($para1, $para2) { ... }, $staticToCallPara1, $sta The dispatcher accepts the resoults from the `route()` method of the router which is an array of routes. ```php -$dispatcher->dispatch($router->route($request)) +$dispatcher->dispatch($router->route($request->getUri()->getRoute())); ``` Based on the function definition returned by the router it's possible to pass more parameters to the function such e.g. request and response objects. ```php -$dispatcher->dispatch($router->route($request), $request, $response) +$dispatcher->dispatch($router->route($request->getUri()->getRoute()), $request, $response); ``` diff --git a/components/modules.md b/components/modules.md index ce6a546..555f38a 100644 --- a/components/modules.md +++ b/components/modules.md @@ -5,6 +5,7 @@ The following directory structure should roughly visualize how modules are struc * {UniqueModuleName} * Admin * Install + * db.json * Navigation.install.json * Navigation.php * Routes @@ -51,6 +52,83 @@ The content of the navigation install file highly depends on the module and shou Some modules can be used without requiring any additional installations it all depends on how the other modules got implemented. Thats also why many modules don't offer any integration at all and are almost stand-alone without the possibility to get extended. +### Database schema + +The database schema of a module is defined in the `db.json` file and is automatically installed during the installation process. + +In the following you can find a sample `db.json` file. + +```json +{ + "task": { + "name": "task", + "fields": { + "task_id": { + "name": "task_id", + "type": "INT", + "null": false, + "primary": true, + "autoincrement": true + }, + "task_title": { + "name": "task_title", + "type": "VARCHAR(255)", + "null": false + }, + "task_desc": { + "name": "task_desc", + "type": "TEXT", + "null": false + }, + "task_type": { + "name": "task_type", + "type": "TINYINT", + "null": false + }, + "task_created_at": { + "name": "task_created_at", + "type": "DATETIME", + "default": null, + "null": true + }, + "task_created_by": { + "name": "task_created_by", + "type": "INT", + "null": false, + "foreignTable": "account", + "foreignKey": "account_id" + } + } + }, + "task_media": { + "name": "task_media", + "fields": { + "task_media_id": { + "name": "task_media_id", + "type": "INT", + "null": false, + "primary": true, + "autoincrement": true + }, + "task_media_src": { + "name": "task_media_src", + "type": "INT", + "null": false, + "foreignTable": "task", + "foreignKey": "task_id" + }, + "task_media_dst": { + "name": "task_media_dst", + "type": "INT", + "null": false, + "foreignTable": "media", + "foreignKey": "media_id" + } + } + } +} +``` + ### Installer.php In contrast to the install file for other modules this file has to follow more strict standards. The following example shows you the bare minimum requirements of a installation file: diff --git a/components/packages.md b/components/packages.md index 1a6a076..724ec76 100644 --- a/components/packages.md +++ b/components/packages.md @@ -34,7 +34,32 @@ In the files directory all files are stored. The `package.json` file contains information of the package. ```json - +{ + "name": "{MODULE_NAME|RESOURCE_NAME|phpOMS|jsOMS|cssOMS}", + "type": "Modules", + "version": "1.0.1", + "update": [ + { + "download": { + "{download_uri}": "{save_to_path/file_name}" + }, + "move": { + "{file_or_directory_to_move}": "{new_destination}" + }, + "copy": { + "{file_or_directory_to_copy}": [ + "{new_destination}" + ] + }, + "delete": [ + "{file_or_directory_to_delete}" + ], + "cmd": [ + "{php|sh|batch_script_to_execute}", + ] + } + ] +} ``` ### Other diff --git a/datastorage/database/queries.md b/datastorage/database/queries.md index 842c5d9..be37841 100644 --- a/datastorage/database/queries.md +++ b/datastorage/database/queries.md @@ -113,4 +113,38 @@ $query->prefix(...)->select(...)->from(...)->where(...)->groupBy('columnA', 'col ### Schema Builder -The schema builder is used for schema related operations such as `DROP`, `CREATE` etc. \ No newline at end of file +The schema builder is used for schema related operations such as `DROP`, `CREATE` etc. + +#### Drop Database + +A database can be dropped with `dropDatabase`. + +```php +$query->dropDatabase('test'); +``` + +#### Create Table + +A table can be created with `createTable`. + +```php +$query->createTable('user_roles') + ->field('user_id', 'INT', null, false, true, true, 'users', 'ext1_id') + ->field('role_id', 'VARCHAR(10)', '1', true, false, false, 'roles', 'ext2_id'); +``` + +#### Show Tables + +All tables of a database can be returned with `selectTables`. + +```php +$query->selectTables(); +``` + +#### Show Table Fields + +All table fields of a table can be returned with `selectFields`. + +```php +$query->selectFields('test'); +``` diff --git a/setup/installation.md b/setup/installation.md index 3044bdb..3a70c91 100644 --- a/setup/installation.md +++ b/setup/installation.md @@ -4,7 +4,7 @@ Installing the application as a developer can be achived by following one of the ## Server Requirements -* PHP >= 7.2 +* PHP >= 7.4 * PDO PHP Extension * mbstring * database such as mysql diff --git a/standards/documentation.md b/standards/documentation.md index 1714d41..5c28f53 100644 --- a/standards/documentation.md +++ b/standards/documentation.md @@ -87,7 +87,7 @@ The javascript documentation is based on JsDoc, therefore only valid JsDoc comme ```js /** - * File description + * File description. * * @package Package name * @copyright Orange Management