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

PersonalDataRequests::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 4
dl 0
loc 9
rs 9.9666
c 0
b 0
f 0
1
<?php
2
3
namespace EventEspresso\core\domain\entities\routing\handlers\admin;
4
5
use EE_Dependency_Map;
6
use EE_Maintenance_Mode;
7
use EventEspresso\core\domain\entities\routing\handlers\Route;
8
use EventEspresso\core\services\loaders\LoaderInterface;
9
use EventEspresso\core\services\request\RequestInterface;
10
11
/**
12
 * Class PersonalDataRequests
13
 * loads resources and dependencies required for user privacy related logic
14
 *
15
 * @package EventEspresso\core\domain\entities\routing\handlers\admin
16
 * @author  Brent Christensen
17
 * @since   \$VID:$
18
 */
19
class PersonalDataRequests extends Route
20
{
21
22
    /**
23
     * @var EE_Maintenance_Mode $maintenance_mode
24
     */
25
    private $maintenance_mode;
26
27
28
    /**
29
     * Route constructor.
30
     *
31
     * @param EE_Dependency_Map   $dependency_map
32
     * @param EE_Maintenance_Mode $maintenance_mode
33
     * @param LoaderInterface     $loader
34
     * @param RequestInterface    $request
35
     */
36
    public function __construct(
37
        EE_Dependency_Map $dependency_map,
38
        EE_Maintenance_Mode $maintenance_mode,
39
        LoaderInterface $loader,
40
        RequestInterface $request
41
    ) {
42
        $this->maintenance_mode = $maintenance_mode;
43
        parent::__construct($dependency_map, $loader, $request);
44
    }
45
46
47
    /**
48
     * returns true if the current request matches this route
49
     *
50
     * @return bool
51
     * @since   $VID:$
52
     */
53
    public function matchesCurrentRequest()
54
    {
55
        return ($this->request->isAdmin() || $this->request->isAjax()) && $this->maintenance_mode->models_can_query();
56
    }
57
58
59
    /**
60
     * @since $VID:$
61
     */
62
    protected function registerDependencies()
63
    {
64
        $this->dependency_map->registerDependencies(
65
            'EventEspresso\core\domain\services\admin\privacy\policy\PrivacyPolicy',
66
            [
67
                'EEM_Payment_Method'                                       => EE_Dependency_Map::load_from_cache,
68
                'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache
69
            ]
70
        );
71
        $this->dependency_map->registerDependencies(
72
            'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendee',
73
            ['EEM_Attendee' => EE_Dependency_Map::load_from_cache]
74
        );
75
        $this->dependency_map->registerDependencies(
76
            'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendeeBillingData',
77
            [
78
                'EEM_Attendee'       => EE_Dependency_Map::load_from_cache,
79
                'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache
80
            ]
81
        );
82
        $this->dependency_map->registerDependencies(
83
            'EventEspresso\core\domain\services\admin\privacy\export\ExportCheckins',
84
            ['EEM_Checkin' => EE_Dependency_Map::load_from_cache]
85
        );
86
        $this->dependency_map->registerDependencies(
87
            'EventEspresso\core\domain\services\admin\privacy\export\ExportRegistration',
88
            ['EEM_Registration' => EE_Dependency_Map::load_from_cache]
89
        );
90
        $this->dependency_map->registerDependencies(
91
            'EventEspresso\core\domain\services\admin\privacy\export\ExportTransaction',
92
            ['EEM_Transaction' => EE_Dependency_Map::load_from_cache]
93
        );
94
        $this->dependency_map->registerDependencies(
95
            'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAttendeeData',
96
            ['EEM_Attendee' => EE_Dependency_Map::load_from_cache]
97
        );
98
        $this->dependency_map->registerDependencies(
99
            'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAnswers',
100
            [
101
                'EEM_Answer'   => EE_Dependency_Map::load_from_cache,
102
                'EEM_Question' => EE_Dependency_Map::load_from_cache,
103
            ]
104
        );
105
        $this->dependency_map->registerDependencies(
106
            'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler',
107
            [
108
                'EE_Registry' => EE_Dependency_Map::load_from_cache,
109
                'EE_Config'   => EE_Dependency_Map::load_from_cache
110
            ]
111
        );
112
    }
113
114
115
    /**
116
     * implements logic required to run during request
117
     *
118
     * @return bool
119
     * @since   $VID:$
120
     */
121
    protected function requestHandler()
122
    {
123
        $this->loader->getShared('EventEspresso\core\services\privacy\erasure\PersonalDataEraserManager');
124
        $this->loader->getShared('EventEspresso\core\services\privacy\export\PersonalDataExporterManager');
125
        return true;
126
    }
127
}
128