mirror of
https://github.com/Karaka-Management/Developer-Guide.git
synced 2026-02-05 07:28:39 +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
|
```php
|
||||||
public function controllerEndpoint(HttpRequest $request, HttpResponse $response, array $data = []) : RenderableInterface
|
public function controllerEndpoint(HttpRequest $request, HttpResponse $response, array $data = []) : RenderableInterface
|
||||||
{
|
{
|
||||||
$view = new View($this->app->l11nManager, $request, $response);
|
$view = new View($this->app->l11nManager, $request, $response);
|
||||||
$view->setTemplate('....');
|
$view->setTemplate('....');
|
||||||
$view->setData('data_id', ....);
|
$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
|
```php
|
||||||
$router->add('foo/bar', function() {
|
$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
|
```php
|
||||||
$router->add('foo/bar', function() {
|
$router->add('foo/bar', function() {
|
||||||
return 'Hello World';
|
return 'Hello World';
|
||||||
}, RouteVerb::GET | RouteVerb::SET);
|
}, RouteVerb::GET | RouteVerb::SET);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
@ -62,17 +62,17 @@ The routing file must have the following structure:
|
||||||
|
|
||||||
```php
|
```php
|
||||||
<?php return [
|
<?php return [
|
||||||
'{ROUTE_STRING}' => [
|
'{ROUTE_STRING}' => [
|
||||||
[
|
[
|
||||||
'dest' => CLOSURE/REFERENCE_STRING,
|
'dest' => CLOSURE/REFERENCE_STRING,
|
||||||
'verb' => VERB_1 | VERB_2,
|
'verb' => VERB_1 | VERB_2,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'dest' => CLOSURE/REFERENCE_STRING,
|
'dest' => CLOSURE/REFERENCE_STRING,
|
||||||
'verb' => VERB_3,
|
'verb' => VERB_3,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'{ANOTHER_ROUTE_STRING}' => [ ... ],
|
'{ANOTHER_ROUTE_STRING}' => [ ... ],
|
||||||
];
|
];
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
@ -108,22 +108,22 @@ $router->route('foo/bar', null, RouteVerb::GET, 'APP_NAME', ORG_ID, ACCOUNT);
|
||||||
|
|
||||||
```php
|
```php
|
||||||
<?php return [
|
<?php return [
|
||||||
'{ROUTE_STRING}' => [
|
'{ROUTE_STRING}' => [
|
||||||
[
|
[
|
||||||
'dest' => CLOSURE/REFERENCE_STRING,
|
'dest' => CLOSURE/REFERENCE_STRING,
|
||||||
'verb' => VERB_1 | VERB_2,
|
'verb' => VERB_1 | VERB_2,
|
||||||
'permission' => [
|
'permission' => [
|
||||||
'module' => NAME,
|
'module' => NAME,
|
||||||
'type' => CREATE | READ | UPDATE | DELETE | PERMISSION,
|
'type' => CREATE | READ | UPDATE | DELETE | PERMISSION,
|
||||||
'state' => MODULE_SPECIFIC_IDENTIFIER_FOR_THE_PERMISSION,
|
'state' => MODULE_SPECIFIC_IDENTIFIER_FOR_THE_PERMISSION,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'dest' => CLOSURE/REFERENCE_STRING,
|
'dest' => CLOSURE/REFERENCE_STRING,
|
||||||
'verb' => VERB_3,
|
'verb' => VERB_3,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'{ANOTHER_ROUTE_STRING}' => [ ... ],
|
'{ANOTHER_ROUTE_STRING}' => [ ... ],
|
||||||
];
|
];
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
@ -147,19 +147,19 @@ Often you would like to enable `CSRF` protection for certain urls or routing pat
|
||||||
|
|
||||||
```php
|
```php
|
||||||
$router->add('foo/bar', function() {
|
$router->add('foo/bar', function() {
|
||||||
return 'Hello World';
|
return 'Hello World';
|
||||||
}, RouteVerb::GET | RouteVerb::SET,
|
}, RouteVerb::GET | RouteVerb::SET,
|
||||||
true, // CSRF token is required
|
true, // CSRF token is required
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
```php
|
```php
|
||||||
$router->route(
|
$router->route(
|
||||||
'foo/bar',
|
'foo/bar',
|
||||||
$request->getData('CSRF'),
|
$request->getData('CSRF'),
|
||||||
RouteVerb::GET,
|
RouteVerb::GET,
|
||||||
'APP_NAME',
|
'APP_NAME',
|
||||||
ORG_ID, ACCOUNT
|
ORG_ID, ACCOUNT
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,8 +33,8 @@ Example:
|
||||||
```php
|
```php
|
||||||
function functionName(mixed $var, $mySetting1, $mySetting2) : bool
|
function functionName(mixed $var, $mySetting1, $mySetting2) : bool
|
||||||
{
|
{
|
||||||
// Do some validation here
|
// Do some validation here
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Validator::isValid($testVariable, ['functionName' => $settings]);
|
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.
|
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.
|
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
|
```php
|
||||||
function(
|
function(
|
||||||
string $para1,
|
string $para1,
|
||||||
int $para2,
|
int $para2,
|
||||||
bool $para3,
|
bool $para3,
|
||||||
array $para4
|
array $para4
|
||||||
) : int
|
) : int
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
@ -80,7 +80,7 @@ echo 'Hello' , 'World';
|
||||||
|
|
||||||
## If
|
## If
|
||||||
|
|
||||||
#### Elseif
|
### Elseif
|
||||||
|
|
||||||
Use `elseif` where possible instead of `else if`.
|
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`)
|
Don't use the internal enum implementations of PHP (neither `SplEnum` nor `enum`)
|
||||||
|
|
||||||
#### Model IDs
|
### Pseudo enums
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
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.
|
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