Code cleaning in example app

This commit is contained in:
Benjamin Renard 2023-02-13 02:43:31 +01:00
parent 5691494f12
commit 799554951b
2 changed files with 25 additions and 5 deletions

View file

@ -10,6 +10,11 @@ use function EesyPHP\vardump;
if (php_sapi_name() == "cli") if (php_sapi_name() == "cli")
return true; return true;
/**
* Search page handler
* @param EesyPHP\UrlRequest $request
* @return void
*/
function handle_search($request) { function handle_search($request) {
global $status_list; global $status_list;
@ -107,10 +112,11 @@ function handle_search($request) {
} }
Url :: add_url_handler('|^item/?$|', 'handle_search'); Url :: add_url_handler('|^item/?$|', 'handle_search');
/* /**
* One item pages * Show one item page handler
* @param EesyPHP\UrlRequest $request
* @return void
*/ */
function handle_show($request) { function handle_show($request) {
$item = get_item_from_url($request -> id); $item = get_item_from_url($request -> id);
if (!$item) if (!$item)
@ -131,6 +137,11 @@ function handle_show($request) {
} }
Url :: add_url_handler('|^item/(?P<id>[0-9]+)$|', 'handle_show'); Url :: add_url_handler('|^item/(?P<id>[0-9]+)$|', 'handle_show');
/**
* Create one item page handler
* @param EesyPHP\UrlRequest $request
* @return void
*/
function handle_create($request) { function handle_create($request) {
global $status_list; global $status_list;
@ -214,6 +225,11 @@ function handle_modify($request) {
} }
Url :: add_url_handler('|^item/(?P<id>[0-9]+)/modify$|', 'handle_modify'); Url :: add_url_handler('|^item/(?P<id>[0-9]+)/modify$|', 'handle_modify');
/**
* Archive one item page handler
* @param EesyPHP\UrlRequest $request
* @return void
*/
function handle_archive($request) { function handle_archive($request) {
$item = get_item_from_url($request -> id); $item = get_item_from_url($request -> id);
if(!is_array($item)) { if(!is_array($item)) {
@ -236,6 +252,11 @@ function handle_archive($request) {
} }
Url :: add_url_handler('|^item/(?P<id>[0-9]+)/archive$|', 'handle_archive'); Url :: add_url_handler('|^item/(?P<id>[0-9]+)/archive$|', 'handle_archive');
/**
* Delete one item page handler
* @param EesyPHP\UrlRequest $request
* @return void
*/
function handle_delete($request) { function handle_delete($request) {
$item = get_item_from_url($request -> id); $item = get_item_from_url($request -> id);
if(!is_array($item)) { if(!is_array($item)) {

View file

@ -5,7 +5,6 @@ include 'url-public.php';
use EesyPHP\Url; use EesyPHP\Url;
$default_url=''; Url :: handle_request('');
Url :: handle_request();
# vim: tabstop=2 shiftwidth=2 softtabstop=2 expandtab # vim: tabstop=2 shiftwidth=2 softtabstop=2 expandtab