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

Loader   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 18
dl 0
loc 34
rs 10
c 1
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A load() 0 25 3
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