1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace EventEspresso\core\services\privacy\erasure; |
4
|
|
|
|
5
|
|
|
use EventEspresso\core\exceptions\InvalidClassException; |
6
|
|
|
use EventEspresso\core\exceptions\InvalidDataTypeException; |
7
|
|
|
use EventEspresso\core\exceptions\InvalidEntityException; |
8
|
|
|
use EventEspresso\core\exceptions\InvalidFilePathException; |
9
|
|
|
use EventEspresso\core\exceptions\InvalidIdentifierException; |
10
|
|
|
use EventEspresso\core\exceptions\InvalidInterfaceException; |
11
|
|
|
use EventEspresso\core\services\collections\CollectionDetails; |
12
|
|
|
use EventEspresso\core\services\collections\CollectionInterface; |
13
|
|
|
use EventEspresso\core\services\collections\CollectionLoader; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Class PersonalDataEraserManager |
17
|
|
|
* Manages setting up the hooks to add the EE core and add-ons' privacy erasers |
18
|
|
|
* |
19
|
|
|
* @package Event Espresso |
20
|
|
|
* @author Mike Nelson |
21
|
|
|
* @since $VID:$ |
22
|
|
|
*/ |
23
|
|
View Code Duplication |
class PersonalDataEraserManager |
24
|
|
|
{ |
25
|
|
|
|
26
|
|
|
public function __construct() |
27
|
|
|
{ |
28
|
|
|
add_filter( |
29
|
|
|
'wp_privacy_personal_data_erasers', |
30
|
|
|
array($this, 'hookInErasers') |
31
|
|
|
); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* For all the registered `PrivateDataEraserInterface`s, add them as erasers |
37
|
|
|
*/ |
38
|
|
|
public function hookInErasers($erasers) |
39
|
|
|
{ |
40
|
|
|
// load all the privacy policy stuff |
41
|
|
|
// add post policy text |
42
|
|
|
foreach ($this->loadPrivateDataEraserCollection() as $eraser) { |
43
|
|
|
$erasers[ get_class($eraser) ] = array( |
44
|
|
|
'eraser_friendly_name' => $eraser->name(), |
45
|
|
|
'callback' => array($eraser, 'erase'), |
46
|
|
|
); |
47
|
|
|
} |
48
|
|
|
return $erasers; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @return CollectionInterface|PersonalDataEraserInterface[] |
54
|
|
|
* @throws InvalidIdentifierException |
55
|
|
|
* @throws InvalidInterfaceException |
56
|
|
|
* @throws InvalidFilePathException |
57
|
|
|
* @throws InvalidEntityException |
58
|
|
|
* @throws InvalidDataTypeException |
59
|
|
|
* @throws InvalidClassException |
60
|
|
|
*/ |
61
|
|
|
protected function loadPrivateDataEraserCollection() |
62
|
|
|
{ |
63
|
|
|
$loader = new CollectionLoader( |
64
|
|
|
new CollectionDetails( |
65
|
|
|
// collection name |
66
|
|
|
'privacy_erasers', |
67
|
|
|
// collection interface |
68
|
|
|
'EventEspresso\core\services\privacy\erasure\PersonalDataEraserInterface', |
69
|
|
|
// FQCNs for classes to add (all classes within that namespace will be loaded) |
70
|
|
|
apply_filters( |
71
|
|
|
'FHEE__EventEspresso_core_services_privacy_erasure_PersonalDataEraserManager__erasers', |
72
|
|
|
array('EventEspresso\core\domain\services\admin\privacy\erasure') |
73
|
|
|
), |
74
|
|
|
// filepaths to classes to add |
75
|
|
|
array(), |
76
|
|
|
// file mask to use if parsing folder for files to add |
77
|
|
|
'', |
78
|
|
|
// what to use as identifier for collection entities |
79
|
|
|
// using CLASS NAME prevents duplicates (works like a singleton) |
80
|
|
|
CollectionDetails::ID_CLASS_NAME |
81
|
|
|
) |
82
|
|
|
); |
83
|
|
|
return $loader->getCollection(); |
84
|
|
|
} |
85
|
|
|
} |
86
|
|
|
// End of file PersonalDataEraserManager.php |
87
|
|
|
// Location: EventEspresso\core\domain\services\admin/PersonalDataEraserManager.php |
88
|
|
|
|