<?php

use App\Core\Template\Output as Output;
use Routes\RouteCollection as RouteCollection;

//Menu itens
RouteCollection::get('*', function() {
    Output::addMenu('/', 'Dashboard', "<i class='fa fa-dashboard'></i>", ['class' => 'nav-link'], -10);
    Output::addMenu('/dre', 'DRE', "<i class='fa fa-bar-chart'></i>", ['class' => 'nav-link'], -10);
}, -10)->doIgnore();

RouteCollection::onHttpError('404', function($code){
    http_response_code(404);
    Output::setTemplate('NullTemplate');
    Output::render('404');
});

RouteCollection::add('get', '/', '\App\Core\Welcome\WelcomeController@welcome');
RouteCollection::add('get', '/teste', '\App\Core\Welcome\WelcomeController@teste');
RouteCollection::add('get', '/dre', '\App\Core\Welcome\WelcomeController@dre');
//Filters

RouteCollection::addDefaultMiddleware('fillpost', function () {

    if(isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'POST'){
        return;
    }

    $_POST = array_merge( $_POST, (array) json_decode( file_get_contents('php://input')) );

});