Test Failed
Push — main ( b6e144...1a2341 )
by Rafael
05:34
created

Loader::load()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 25
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 17
nc 3
nop 0
dl 0
loc 25
rs 9.7
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
7
namespace Alxarafe\Core\Helpers;
8
9
use Alxarafe\Controllers\EditConfig;
10
use Alxarafe\Core\Singletons\Config;
11
use Alxarafe\Core\Singletons\Debug;
12
use Alxarafe\Core\Singletons\FlashMessages;
13
use Alxarafe\Core\Singletons\Logger;
14
use Alxarafe\Core\Singletons\PhpFileCache;
15
use Alxarafe\Core\Singletons\RegionalInfo;
16
use Alxarafe\Core\Singletons\Render;
17
use Alxarafe\Core\Singletons\Session;
18
use Alxarafe\Core\Singletons\Translator;
19
use Alxarafe\Database\DB;
20
use Alxarafe\Database\YamlSchema;
21
use Alxarafe\Database\Schema;
22
23
/**
24
 * Class Loader
25
 *
26
 * Inicializa las clases globales
27
 *
28
 * @author  Rafael San José Tovar <[email protected]>
29
 *
30
 * @package Alxarafe\Core\Helpers
31
 */
32
abstract class Loader
33
{
34
    /**
35
     * Inicializa todas las clases necesarias para que el núcleo funcione
36
     *
37
     * @author Rafael San José Tovar <[email protected]>
38
     *
39
     * @throws \DebugBar\DebugBarException
40
     */
41
    public static function load()
42
    {
43
        Globals::load();
44
        Config::load();
45
        FlashMessages::load();
46
        RegionalInfo::load();
47
        Logger::load();
48
        Debug::load();
49
        Translator::load();
50
        Render::load();
51
        PhpFileCache::load();
52
53
        if (!DB::connectToDatabase()) {
54
            FlashMessages::setError(Translator::trans('database-connection-error'));
55
            $run = new EditConfig();
56
            $run->main();
57
            die();
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
58
        }
59
60
        // TODO: Sólo debería de limpiarse caché al activar y desactivar un plugin, o a demanda.
61
        //       Pero en modo de depuración, debería de limpiarse para actualizar los cambios en las tablas.
62
        if (!YamlSchema::clearYamlCache()) {
63
            die('No se ha podido eliminar la caché');
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
64
        }
65
        Schema::checkDatabaseStructure();
66
    }
67
}
68