Startup   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Importance

Changes 0
Metric Value
dl 0
loc 50
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 6

1 Method

Rating   Name   Duplication   Size   Complexity  
B rescue() 0 39 2
1
<?php
2
3
/**
4
 * Tries to continue on startup trouble
5
 *
6
 * PHP Version 5
7
 *
8
 * @category  Core
9
 * @package   Errors
10
 * @author    Hans-Joachim Piepereit <[email protected]>
11
 * @copyright 2013 cSphere Team
12
 * @license   http://opensource.org/licenses/bsd-license Simplified BSD License
13
 * @link      http://www.csphere.eu
14
 **/
15
16
namespace csphere\core\errors;
17
18
/**
19
 * Tries to continue on startup trouble
20
 *
21
 * @category  Core
22
 * @package   Errors
23
 * @author    Hans-Joachim Piepereit <[email protected]>
24
 * @copyright 2013 cSphere Team
25
 * @license   http://opensource.org/licenses/bsd-license Simplified BSD License
26
 * @link      http://www.csphere.eu
27
 **/
28
29
class Startup
30
{
31
    /**
32
     * Necessity begets ingenuity
33
     *
34
     * @param array $error Error as an array
35
     *
36
     * @return void
37
     **/
0 ignored issues
show
Coding Style introduced by
There must be no blank lines after the function comment
Loading history...
38
39
    public static function rescue(array $error)
40
    {
41
        // Get service loader
42
        $loader = \csphere\core\service\Locator::get();
43
44
        // Check if installation is going on
45
        $plugin = \csphere\core\http\Input::get('get', 'plugin');
46
47
        if ($plugin == 'install') {
48
49
            // Deactivate driver fallbacks (only) here
50
            $loader->rescue(false);
51
52
            $router = new \csphere\core\router\Controller(true);
53
54
            $router->execute();
55
56
        } else {
57
58
            // Inform template engine about the target
59
            \csphere\core\template\Hooks::route('errors', 'config');
60
61
            // Get view object
62
            $view = $loader->load('view');
63
64
            // Format data for template usage
65
            $data = ['file' => $error['file']];
66
67
            $data['error'] = \csphere\core\translation\Fetch::key(
68
                'errors', $error['error']
69
            );
70
71
            // Send data to view and fetch result
72
            $view->template('errors', 'core_config', $data);
73
74
            $router = new \csphere\core\router\Controller();
75
            $router->execute(true);
76
        }
77
    }
78
}
79