Completed
Branch EDTR/master (6bd139)
by
unknown
35:03 queued 26:41
created

RoutingRequests   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 73
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 73
rs 10
c 0
b 0
f 0
wmc 5
lcom 2
cbo 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A registerDependencies() 0 42 2
A requestHandler() 0 4 1
A matchesCurrentRequest() 0 4 2
1
<?php
2
3
namespace EventEspresso\core\domain\entities\routing\handlers\shared;
4
5
use EE_Dependency_Map;
6
use EventEspresso\core\domain\entities\routing\handlers\Route;
7
8
/**
9
 * Class RoutingRequests
10
 * registers dependencies for all other Routes as long as this is not an activation request
11
 *
12
 * @package EventEspresso\core\domain\entities\routing\handlers\shared
13
 * @author  Brent Christensen
14
 * @since   \$VID:$
15
 */
16
class RoutingRequests extends Route
17
{
18
19
    /**
20
     * returns true if the current request matches this route
21
     *
22
     * @return bool
23
     * @since   $VID:$
24
     */
25
    public function matchesCurrentRequest()
26
    {
27
        return ! $this->request->isActivation() || $this->request->isUnitTesting();
28
    }
29
30
31
    /**
32
     * @since $VID:$
33
     */
34
    protected function registerDependencies()
35
    {
36
        $default = [
37
            'EE_Dependency_Map'                           => EE_Dependency_Map::load_from_cache,
38
            'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
39
            'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
40
        ];
41
        $admin = [
42
            'EE_Admin_Config'                             => EE_Dependency_Map::load_from_cache,
43
            'EE_Dependency_Map'                           => EE_Dependency_Map::load_from_cache,
44
            'EE_Maintenance_Mode'                         => EE_Dependency_Map::load_from_cache,
45
            'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
46
            'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
47
        ];
48
        $frontend = [
49
            'EE_Dependency_Map'                           => EE_Dependency_Map::load_from_cache,
50
            'EE_Maintenance_Mode'                         => EE_Dependency_Map::load_from_cache,
51
            'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
52
            'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
53
        ];
54
        $default_routes = [
55
            // admin dependencies
56
            'EventEspresso\core\domain\entities\routing\handlers\admin\EspressoEventsAdmin' => $admin,
57
            'EventEspresso\core\domain\entities\routing\handlers\admin\EspressoEventEditor' => $admin,
58
            'EventEspresso\core\domain\entities\routing\handlers\admin\EspressoLegacyAdmin' => $admin,
59
            // default dependencies
60
            'EventEspresso\core\domain\entities\routing\handlers\admin\PueRequests' => $default,
61
            'EventEspresso\core\domain\entities\routing\handlers\admin\WordPressPluginsPage' => $default,
62
            'EventEspresso\core\domain\entities\routing\handlers\frontend\ShortcodeRequests' => $default,
63
            'EventEspresso\core\domain\entities\routing\handlers\shared\AssetRequests' => $default,
64
            'EventEspresso\core\domain\entities\routing\handlers\shared\GQLRequests' => $default,
65
            'EventEspresso\core\domain\entities\routing\handlers\shared\RestApiRequests' => $default,
66
            'EventEspresso\core\domain\entities\routing\handlers\shared\SessionRequests' => $default,
67
            'EventEspresso\core\domain\entities\routing\handlers\shared\WordPressHeartbeat' => $default,
68
            // frontend dependencies
69
            'EventEspresso\core\domain\entities\routing\handlers\admin\PersonalDataRequests' => $frontend,
70
            'EventEspresso\core\domain\entities\routing\handlers\frontend\FrontendRequests' => $frontend,
71
        ];
72
        foreach ($default_routes as $route => $dependencies) {
73
            $this->dependency_map->registerDependencies($route, $dependencies);
74
        }
75
    }
76
77
78
    /**
79
     * implements logic required to run during request
80
     *
81
     * @return bool
82
     * @since   $VID:$
83
     */
84
    protected function requestHandler()
85
    {
86
        return true;
87
    }
88
}
89