RouteController::printRoutes()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 4
ccs 0
cts 3
cp 0
crap 2
rs 10
1
<?php
2
3
namespace PSFS\controller;
4
5
use Exception;
6
use PSFS\base\Logger;
7
use PSFS\base\Router;
8
use PSFS\base\Security;
9
use PSFS\controller\base\Admin;
10
11
/**
12
 * Class RouteController
13
 * @package PSFS\controller
14
 */
15
class RouteController extends Admin
16
{
17
    /**
18
     * Método que pinta por pantalla todas las rutas del sistema
19
     * @GET
20
     * @label Visor de rutas del sistema
21
     * @icon fa-folder-tree
22
     * @route /admin/routes
23
     */
24
    public function printRoutes()
25
    {
26
        return $this->render('routing.html.twig', array(
27
            'slugs' => Router::getInstance()->getAllRoutes(),
28
        ));
29
    }
30
31
    /**
32
     * Servicio que devuelve los parámetros disponibles
33
     * @GET
34
     * @route /admin/routes/show
35
     * @label Servicio de rutas del sistema
36
     * @visible false
37
     * @return mixed
38
     */
39
    public function getRouting()
40
    {
41
        $response = Router::getInstance()->getSlugs();
42
        return $this->json($response);
43
    }
44
45
    /**
46
     * Service to regenerate routes
47
     * @GET
48
     * @route /admin/routes/gen
49
     * @label Regenerar rutas
50
     * @visible false
51
     * @return string HTML
52
     */
53
    public function regenerateUrls()
54
    {
55
        $router = Router::getInstance();
56
        try {
57
            $router->hydrateRouting();
58
            $router->simpatize();
59
            Security::getInstance()->setFlash("callback_message", t("Rutas generadas correctamente"));
60
            Security::getInstance()->setFlash("callback_route", $this->getRoute("admin-routes", true));
61
        } catch (Exception $e) {
62
            Logger::log($e->getMessage(), LOG_ERR);
63
            Security::getInstance()->setFlash("callback_message", t("Algo no ha salido bien, revisa los logs"));
64
            Security::getInstance()->setFlash("callback_route", $this->getRoute("admin-routes", true));
65
        }
66
        return $this->redirect('admin-routes');
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->redirect('admin-routes') targeting PSFS\base\types\Controller::redirect() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
67
    }
68
}
69