Esempio n. 1
0
function router()
{
    $config = getConfig();
    $uri = $_SERVER['REQUEST_URI'];
    $type = $_SERVER['REQUEST_METHOD'];
    $routers = $config['route'];
    $action = null;
    foreach ($routers as $key => $value) {
        if (preg_match($key, $uri)) {
            if ($type === $value['type']) {
                $action = $value['action'];
                $action();
                break;
            }
        }
    }
    if (empty($action)) {
        $twig = getTwig();
        echo $twig->render('/View/404.html.twig', ['uri' => $uri]);
    }
}
Esempio n. 2
0
function editAction()
{
    $twig = getTwig();
    $item = getItemsByIds([$_GET['id']])[0];
    echo $twig->render('/View/edit.html.twig', ['action' => '/update', 'item' => $item]);
}
Esempio n. 3
0
function homeAction()
{
    $twig = getTwig();
    echo $twig->render('/View/home.html.twig', []);
}
Esempio n. 4
0
function newAction()
{
    $twig = getTwig();
    echo $twig->render('/View/new.html.twig', ['action' => '/create']);
}