Completed
Branch EDTR/master (810f49)
by
unknown
28:59 queued 20:31
created

SessionRequests::matchesCurrentRequest()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
nc 3
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
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 SessionRequests
10
 * registers dependencies and loads resources for requests where EE_Session may be required
11
 *
12
 * @package EventEspresso\core\domain\entities\routing\handlers\shared
13
 * @author  Brent Christensen
14
 * @since   \$VID:$
15
 */
16
class SessionRequests 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->isAdmin() || $this->request->isEeAjax() || $this->request->isFrontend();
28
    }
29
30
31
    /**
32
     * @since $VID:$
33
     */
34 View Code Duplication
    protected function registerDependencies()
35
    {
36
        $this->dependency_map->registerDependencies(
37
            'EE_Session',
38
            [
39
                'EventEspresso\core\services\cache\TransientCacheStorage'  => EE_Dependency_Map::load_from_cache,
40
                'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
41
                'EventEspresso\core\services\request\Request'              => EE_Dependency_Map::load_from_cache,
42
                'EventEspresso\core\services\session\SessionStartHandler'  => EE_Dependency_Map::load_from_cache,
43
                'EE_Encryption'                                            => EE_Dependency_Map::load_from_cache,
44
            ]
45
        );
46
        $this->dependency_map->registerDependencies(
47
            'EventEspresso\core\services\session\SessionStartHandler',
48
            ['EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache]
49
        );
50
    }
51
52
53
    /**
54
     * implements logic required to run during request
55
     *
56
     * @return bool
57
     * @since   $VID:$
58
     */
59
    protected function requestHandler()
60
    {
61
        $this->loader->getShared('EE_Session');
62
        return true;
63
    }
64
}
65