mirror of
https://github.com/Karaka-Management/Developer-Guide.git
synced 2026-01-11 12:28:41 +00:00
style fixes
This commit is contained in:
parent
1346dc247e
commit
867d671126
|
|
@ -66,11 +66,11 @@ In most cases the text/html response is created based on a `View` which has a te
|
|||
```php
|
||||
public function controllerEndpoint(HttpRequest $request, HttpResponse $response, array $data = []) : RenderableInterface
|
||||
{
|
||||
$view = new View($this->app->l11nManager, $request, $response);
|
||||
$view->setTemplate('....');
|
||||
$view->setData('data_id', ....);
|
||||
$view = new View($this->app->l11nManager, $request, $response);
|
||||
$view->setTemplate('....');
|
||||
$view->setData('data_id', ....);
|
||||
|
||||
return $view;
|
||||
return $view;
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ For routes it's possible to define a `\Closure` which will get returned upon usi
|
|||
|
||||
```php
|
||||
$router->add('foo/bar', function() {
|
||||
return 'Hello World';
|
||||
return 'Hello World';
|
||||
});
|
||||
```
|
||||
|
||||
|
|
@ -32,7 +32,7 @@ Routes can have different verbs which are derived from the HTTP verbs. Routes th
|
|||
|
||||
```php
|
||||
$router->add('foo/bar', function() {
|
||||
return 'Hello World';
|
||||
return 'Hello World';
|
||||
}, RouteVerb::GET | RouteVerb::SET);
|
||||
```
|
||||
|
||||
|
|
@ -62,17 +62,17 @@ The routing file must have the following structure:
|
|||
|
||||
```php
|
||||
<?php return [
|
||||
'{ROUTE_STRING}' => [
|
||||
[
|
||||
'dest' => CLOSURE/REFERENCE_STRING,
|
||||
'verb' => VERB_1 | VERB_2,
|
||||
],
|
||||
[
|
||||
'dest' => CLOSURE/REFERENCE_STRING,
|
||||
'verb' => VERB_3,
|
||||
],
|
||||
],
|
||||
'{ANOTHER_ROUTE_STRING}' => [ ... ],
|
||||
'{ROUTE_STRING}' => [
|
||||
[
|
||||
'dest' => CLOSURE/REFERENCE_STRING,
|
||||
'verb' => VERB_1 | VERB_2,
|
||||
],
|
||||
[
|
||||
'dest' => CLOSURE/REFERENCE_STRING,
|
||||
'verb' => VERB_3,
|
||||
],
|
||||
],
|
||||
'{ANOTHER_ROUTE_STRING}' => [ ... ],
|
||||
];
|
||||
```
|
||||
|
||||
|
|
@ -108,22 +108,22 @@ $router->route('foo/bar', null, RouteVerb::GET, 'APP_NAME', ORG_ID, ACCOUNT);
|
|||
|
||||
```php
|
||||
<?php return [
|
||||
'{ROUTE_STRING}' => [
|
||||
[
|
||||
'dest' => CLOSURE/REFERENCE_STRING,
|
||||
'verb' => VERB_1 | VERB_2,
|
||||
'permission' => [
|
||||
'module' => NAME,
|
||||
'type' => CREATE | READ | UPDATE | DELETE | PERMISSION,
|
||||
'state' => MODULE_SPECIFIC_IDENTIFIER_FOR_THE_PERMISSION,
|
||||
],
|
||||
],
|
||||
[
|
||||
'dest' => CLOSURE/REFERENCE_STRING,
|
||||
'verb' => VERB_3,
|
||||
],
|
||||
],
|
||||
'{ANOTHER_ROUTE_STRING}' => [ ... ],
|
||||
'{ROUTE_STRING}' => [
|
||||
[
|
||||
'dest' => CLOSURE/REFERENCE_STRING,
|
||||
'verb' => VERB_1 | VERB_2,
|
||||
'permission' => [
|
||||
'module' => NAME,
|
||||
'type' => CREATE | READ | UPDATE | DELETE | PERMISSION,
|
||||
'state' => MODULE_SPECIFIC_IDENTIFIER_FOR_THE_PERMISSION,
|
||||
],
|
||||
],
|
||||
[
|
||||
'dest' => CLOSURE/REFERENCE_STRING,
|
||||
'verb' => VERB_3,
|
||||
],
|
||||
],
|
||||
'{ANOTHER_ROUTE_STRING}' => [ ... ],
|
||||
];
|
||||
```
|
||||
|
||||
|
|
@ -147,19 +147,19 @@ Often you would like to enable `CSRF` protection for certain urls or routing pat
|
|||
|
||||
```php
|
||||
$router->add('foo/bar', function() {
|
||||
return 'Hello World';
|
||||
}, RouteVerb::GET | RouteVerb::SET,
|
||||
true, // CSRF token is required
|
||||
return 'Hello World';
|
||||
}, RouteVerb::GET | RouteVerb::SET,
|
||||
true, // CSRF token is required
|
||||
);
|
||||
```
|
||||
|
||||
```php
|
||||
$router->route(
|
||||
'foo/bar',
|
||||
$request->getData('CSRF'),
|
||||
RouteVerb::GET,
|
||||
'APP_NAME',
|
||||
ORG_ID, ACCOUNT
|
||||
'foo/bar',
|
||||
$request->getData('CSRF'),
|
||||
RouteVerb::GET,
|
||||
'APP_NAME',
|
||||
ORG_ID, ACCOUNT
|
||||
);
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -33,8 +33,8 @@ Example:
|
|||
```php
|
||||
function functionName(mixed $var, $mySetting1, $mySetting2) : bool
|
||||
{
|
||||
// Do some validation here
|
||||
return true;
|
||||
// Do some validation here
|
||||
return true;
|
||||
}
|
||||
|
||||
Validator::isValid($testVariable, ['functionName' => $settings]);
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
The php code needs to be php 8.1 compliant. No php 8.1 deprecated or removed elements, functions or practices are allowed (e.g. short open tag). Please use the `phpcs.xml` configuration for PHP Code Sniffer to identify most of the basic code standards.
|
||||
|
||||
## Php Tags
|
||||
## Php Tags
|
||||
|
||||
PHP code MUST use the long `<?php ?>` tags or the short-echo `<?= ?>` tags; it MUST NOT use the other tag variations.
|
||||
|
||||
|
|
@ -31,10 +31,10 @@ or for multiline function parameters
|
|||
|
||||
```php
|
||||
function(
|
||||
string $para1,
|
||||
int $para2,
|
||||
bool $para3,
|
||||
array $para4
|
||||
string $para1,
|
||||
int $para2,
|
||||
bool $para3,
|
||||
array $para4
|
||||
) : int
|
||||
{
|
||||
|
||||
|
|
@ -80,7 +80,7 @@ echo 'Hello' , 'World';
|
|||
|
||||
## If
|
||||
|
||||
#### Elseif
|
||||
### Elseif
|
||||
|
||||
Use `elseif` where possible instead of `else if`.
|
||||
|
||||
|
|
@ -114,11 +114,7 @@ Instead of using `\file_exists()` the functions `\is_dir()` or `\is_file()` shou
|
|||
|
||||
Don't use the internal enum implementations of PHP (neither `SplEnum` nor `enum`)
|
||||
|
||||
#### Model IDs
|
||||
|
||||
Model IDs must always be private. They must not have a setter. Therfore most models need/should have a getter function which returns the model ID.
|
||||
|
||||
#### Pseudo enums
|
||||
### Pseudo enums
|
||||
|
||||
Whenever a scalar coming from the internal enum data type (`\phpOMS\Stdlib\Base\Enum`) is used the variable should be private and a getter and setter should exist for additional type checks.
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user