Test Failed
Push — master ( ed0f4f...3aebc2 )
by Alxarafe
43:14
created

AlixarDispatcher::process()   A

Complexity

Conditions 5
Paths 3

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 9
nc 3
nop 0
dl 0
loc 15
rs 9.6111
c 0
b 0
f 0
1
<?php
2
/**
3
 * Alxarafe. Development of PHP applications in a flash!
4
 * Copyright (C) 2018 Alxarafe <[email protected]>
5
 */
6
namespace Alixar\Helpers;
7
8
class AlixarDispatcher extends \Alxarafe\Helpers\Dispatcher
9
{
10
11
    public $path;
12
13
    public function __construct()
14
    {
15
        parent::__construct();
16
17
        $this->searchDir[] = BASE_PATH . '/plugins';
18
        $path = null;
19
    }
20
21
    /**
22
     * Define the constants of the application
23
     */
24
    public function defineConstants()
25
    {
26
        parent::defineConstants();
27
28
        /**
29
         * Alixar is a fork of Dolibarr powered with Alxarafe
30
         * Alxarafe. Development of PHP applications in a flash!
31
         * Copyright (C) 2018 Alxarafe <[email protected]>
32
         */
33
        /**
34
35
          define('APP_URI', pathinfo(filter_input(INPUT_SERVER, 'SCRIPT_NAME'), PATHINFO_DIRNAME));
36
37
          define('SERVER_NAME', filter_input(INPUT_SERVER, 'SERVER_NAME'));
38
          define('APP_PROTOCOL', filter_input(INPUT_SERVER, 'REQUEST_SCHEME'));
39
          define('SITE_URL', APP_PROTOCOL . '://' . SERVER_NAME);
40
          define('BASE_URI', SITE_URL . APP_URI);
41
         */
42
        define('DOL_BASE_PATH', BASE_PATH . '/dolibarr/htdocs');
43
        define('DOL_BASE_URI', BASE_URI . '/dolibarr/htdocs');
44
//define('DOL_DOCUMENT_ROOT', DOL_BASE_PATH);
45
46
        define('CORE_FOLDER', '/core');
47
        define('CONFIG_FOLDER', '/core');
48
        define('CONTROLLERS_FOLDER', '/controllers');
49
        define('HELPERS_FOLDER', '/helpers');
50
        define('MODELS_FOLDER', '/models');
51
        define('SKINS_FOLDER', '/views/skins');
52
        define('TEMPLATES_FOLDER', '/views/templates');
53
        define('PLUGINS_FOLDER', '/plugins');
54
        define('CACHE_FOLDER', '/../cache');
55
        //define('VENDOR_FOLDER', BASE_URI . '/vendor');
56
57
        define('CORE_PATH', BASE_PATH . CORE_FOLDER);
58
        define('CONFIG_PATH', BASE_PATH . CONFIG_FOLDER);
59
        define('CONTROLLERS_PATH', BASE_PATH . CONTROLLERS_FOLDER);
60
        define('HELPERS_PATH', BASE_PATH . HELPERS_FOLDER);
61
        define('MODELS_PATH', BASE_PATH . MODELS_FOLDER);
62
        define('SKINS_PATH', BASE_PATH . SKINS_FOLDER);
63
        define('TEMPLATES_PATH', BASE_PATH . TEMPLATES_FOLDER);
64
        define('PLUGINS_PATH', BASE_PATH . PLUGINS_FOLDER);
65
        define('CACHE_PATH', BASE_PATH . CACHE_FOLDER);
66
        //define('VENDOR_PATH', BASE_PATH . VENDOR_FOLDER);
67
    }
68
69
    public function process()
70
    {
71
        if (parent::process()) {
72
            return;
73
        }
74
75
        $controller = filter_input(INPUT_GET, 'controller') ?: 'home';
76
        $method = filter_input(INPUT_GET, 'method') ?: 'home';
77
78
        $this->path = "dolibarr/htdocs/$controller/$method.php";
79
        if (file_exists($this->path)) {
80
            return true;
81
        }
82
        $this->path = null;
83
        return false;
84
    }
85
}
86